refactor: add typed decoder plugin runtime
This commit is contained in:
@@ -253,15 +253,15 @@
|
||||
updateHfAprsSummary();
|
||||
updateHfAprsChipState();
|
||||
}
|
||||
hfAprsWindow.resetHfAprsHistoryView = function() {
|
||||
function resetHfAprsHistoryView() {
|
||||
if (hfAprsPacketsEl) hfAprsPacketsEl.innerHTML = "";
|
||||
hfAprsPacketHistory = [];
|
||||
renderHfAprsHistory();
|
||||
};
|
||||
hfAprsWindow.pruneHfAprsHistoryView = function() {
|
||||
}
|
||||
function pruneHfAprsHistoryView() {
|
||||
pruneHfAprsPacketHistory();
|
||||
renderHfAprsHistory();
|
||||
};
|
||||
}
|
||||
function addHfAprsPacket(pkt) {
|
||||
const tsMs = Number.isFinite(pkt.ts_ms) ? Number(pkt.ts_ms) : Date.now();
|
||||
pkt._tsMs = tsMs;
|
||||
@@ -273,7 +273,7 @@
|
||||
function normalizeServerHfAprsPacket(pkt) {
|
||||
return normalizeAprsPacket(pkt, hfAprsWindow.getDecodeRigMeta?.() ?? null);
|
||||
}
|
||||
hfAprsWindow.onServerHfAprsBatch = function(packets) {
|
||||
function onServerHfAprsBatch(packets) {
|
||||
if (!Array.isArray(packets) || packets.length === 0) return;
|
||||
if (hfAprsStatus) hfAprsStatus.textContent = "Receiving";
|
||||
const normalized = [];
|
||||
@@ -288,10 +288,7 @@
|
||||
hfAprsPacketHistory = normalized.concat(hfAprsPacketHistory);
|
||||
pruneHfAprsPacketHistory();
|
||||
scheduleHfAprsHistoryRender();
|
||||
};
|
||||
hfAprsWindow.restoreHfAprsHistory = function(packets) {
|
||||
hfAprsWindow.onServerHfAprsBatch?.(packets);
|
||||
};
|
||||
}
|
||||
var hfAprsDecodeToggleBtn = document.getElementById("hf-aprs-decode-toggle-btn");
|
||||
hfAprsDecodeToggleBtn?.addEventListener("click", () => {
|
||||
void (async () => {
|
||||
@@ -308,7 +305,7 @@
|
||||
if (!await hfAprsWindow.trxUi.confirm({ title: "Clear HF APRS history?", message: "All stored HF APRS packets will be permanently removed.", confirmLabel: "Clear history" })) return;
|
||||
try {
|
||||
await hfAprsWindow.postPath?.("/clear_hf_aprs_decode");
|
||||
hfAprsWindow.resetHfAprsHistoryView?.();
|
||||
resetHfAprsHistoryView();
|
||||
} catch (e) {
|
||||
console.error("HF APRS history clear failed", e);
|
||||
}
|
||||
@@ -346,10 +343,17 @@
|
||||
renderHfAprsHistory();
|
||||
});
|
||||
}
|
||||
hfAprsWindow.onServerHfAprs = function(pkt) {
|
||||
function onServerHfAprs(pkt) {
|
||||
if (hfAprsStatus) hfAprsStatus.textContent = "Receiving";
|
||||
addHfAprsPacket(normalizeServerHfAprsPacket(pkt));
|
||||
};
|
||||
}
|
||||
renderHfAprsHistory();
|
||||
hfAprsWindow._trxDrainPendingDecode?.("hf_aprs");
|
||||
window.trxPluginRuntime.registerDecoder({
|
||||
id: "hf_aprs",
|
||||
onMessage: onServerHfAprs,
|
||||
onBatch: onServerHfAprsBatch,
|
||||
restore: onServerHfAprsBatch,
|
||||
reset: resetHfAprsHistoryView,
|
||||
prune: pruneHfAprsHistoryView
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user