refactor: route all decoders through plugin runtime
This commit is contained in:
@@ -205,7 +205,7 @@
|
||||
scheduleWefaxUi("wefax-history", renderWefaxHistoryTable);
|
||||
}
|
||||
}
|
||||
wefaxWindow.onServerWefaxProgress = function(msg) {
|
||||
function onServerWefaxProgress(msg) {
|
||||
if (msg.state && !msg.line_data) {
|
||||
if (wefaxDom.status) {
|
||||
wefaxDom.status.textContent = msg.state;
|
||||
@@ -229,16 +229,16 @@
|
||||
wefaxDom.status.textContent = `Receiving — line ${String(msg.line_count ?? 0)}`;
|
||||
wefaxDom.status.style.color = "var(--text-accent)";
|
||||
}
|
||||
};
|
||||
wefaxWindow.onServerWefax = function(msg) {
|
||||
}
|
||||
function onServerWefax(msg) {
|
||||
addWefaxImage(msg);
|
||||
if (wefaxDom.liveContainer) wefaxDom.liveContainer.style.display = "none";
|
||||
if (wefaxDom.status) {
|
||||
wefaxDom.status.textContent = `Complete — ${String(msg.line_count ?? 0)} lines`;
|
||||
wefaxDom.status.style.color = "";
|
||||
}
|
||||
};
|
||||
wefaxWindow.restoreWefaxHistory = function(messages) {
|
||||
}
|
||||
function restoreWefaxHistory(messages) {
|
||||
if (!messages.length) return;
|
||||
for (const message of messages) {
|
||||
const tsMs = Number.isFinite(message.ts_ms) ? Number(message.ts_ms) : Date.now();
|
||||
@@ -255,13 +255,13 @@
|
||||
if (wefaxActiveView === "history") {
|
||||
scheduleWefaxUi("wefax-history", renderWefaxHistoryTable);
|
||||
}
|
||||
};
|
||||
wefaxWindow.pruneWefaxHistoryView = function() {
|
||||
}
|
||||
function pruneWefaxHistoryView() {
|
||||
pruneWefaxHistory();
|
||||
renderWefaxHistoryTable();
|
||||
renderWefaxLatestCard();
|
||||
};
|
||||
wefaxWindow.resetWefaxHistoryView = function() {
|
||||
}
|
||||
function resetWefaxHistoryView() {
|
||||
wefaxImageHistory = [];
|
||||
if (wefaxDom.historyList) wefaxDom.historyList.innerHTML = "";
|
||||
if (wefaxDom.liveContainer) wefaxDom.liveContainer.style.display = "none";
|
||||
@@ -273,7 +273,7 @@
|
||||
wefaxDom.status.textContent = "Idle";
|
||||
wefaxDom.status.style.color = "";
|
||||
}
|
||||
};
|
||||
}
|
||||
if (wefaxDom.filterInput) {
|
||||
const filterInput = wefaxDom.filterInput;
|
||||
wefaxDom.filterInput.addEventListener("input", function() {
|
||||
@@ -313,7 +313,7 @@
|
||||
void (async () => {
|
||||
try {
|
||||
await wefaxWindow.postPath?.("/clear_wefax_decode");
|
||||
wefaxWindow.resetWefaxHistoryView?.();
|
||||
resetWefaxHistoryView();
|
||||
} catch (e) {
|
||||
console.error("WEFAX clear failed", e);
|
||||
}
|
||||
@@ -321,4 +321,15 @@
|
||||
});
|
||||
}
|
||||
renderWefaxLatestCard();
|
||||
wefaxWindow.trxPluginRuntime.registerDecoder({
|
||||
id: "wefax",
|
||||
onMessage: onServerWefax,
|
||||
restore: restoreWefaxHistory,
|
||||
prune: pruneWefaxHistoryView,
|
||||
reset: resetWefaxHistoryView
|
||||
});
|
||||
wefaxWindow.trxPluginRuntime.registerDecoder({
|
||||
id: "wefax_progress",
|
||||
onMessage: onServerWefaxProgress
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user