refactor: add typed decoder plugin runtime
This commit is contained in:
@@ -291,7 +291,7 @@
|
||||
}
|
||||
aprsWindow.updateAprsBar = updateAprsBar;
|
||||
aprsWindow.clearAprsBar = function() {
|
||||
aprsWindow.resetAprsHistoryView?.();
|
||||
resetAprsHistoryView();
|
||||
};
|
||||
aprsWindow.closeAprsBar = function() {
|
||||
aprsBarDismissedAtMs = Date.now();
|
||||
@@ -300,18 +300,18 @@
|
||||
aprsBarOverlay.innerHTML = "";
|
||||
}
|
||||
};
|
||||
aprsWindow.resetAprsHistoryView = function() {
|
||||
function resetAprsHistoryView() {
|
||||
if (aprsPacketsEl) aprsPacketsEl.innerHTML = "";
|
||||
aprsPacketHistory = [];
|
||||
updateAprsBar();
|
||||
renderAprsHistory();
|
||||
aprsWindow.clearMapMarkersByType?.("aprs");
|
||||
};
|
||||
aprsWindow.pruneAprsHistoryView = function() {
|
||||
}
|
||||
function pruneAprsHistoryView() {
|
||||
pruneAprsPacketHistory();
|
||||
updateAprsBar();
|
||||
renderAprsHistory();
|
||||
};
|
||||
}
|
||||
function addAprsPacket(pkt) {
|
||||
const tsMs = Number.isFinite(pkt.ts_ms) ? Number(pkt.ts_ms) : Date.now();
|
||||
pkt._tsMs = tsMs;
|
||||
@@ -327,7 +327,7 @@
|
||||
function normalizeServerAprsPacket(pkt) {
|
||||
return normalizeAprsPacket(pkt, aprsWindow.getDecodeRigMeta?.() ?? null);
|
||||
}
|
||||
aprsWindow.onServerAprsBatch = function(packets) {
|
||||
function onServerAprsBatch(packets) {
|
||||
if (!Array.isArray(packets) || packets.length === 0) return;
|
||||
if (aprsStatus) aprsStatus.textContent = "Receiving";
|
||||
const normalized = [];
|
||||
@@ -348,16 +348,13 @@
|
||||
pruneAprsPacketHistory();
|
||||
if (hasCrcOk) scheduleAprsBarUpdate();
|
||||
scheduleAprsHistoryRender();
|
||||
};
|
||||
aprsWindow.restoreAprsHistory = function(packets) {
|
||||
aprsWindow.onServerAprsBatch?.(packets);
|
||||
};
|
||||
}
|
||||
document.getElementById("settings-clear-aprs-history")?.addEventListener("click", () => {
|
||||
void (async () => {
|
||||
if (!await aprsWindow.trxUi.confirm({ title: "Clear APRS history?", message: "All stored APRS packets will be permanently removed.", confirmLabel: "Clear history" })) return;
|
||||
try {
|
||||
await aprsWindow.postPath?.("/clear_aprs_decode");
|
||||
aprsWindow.resetAprsHistoryView?.();
|
||||
resetAprsHistoryView();
|
||||
} catch (e) {
|
||||
console.error("APRS history clear failed", e);
|
||||
}
|
||||
@@ -395,10 +392,17 @@
|
||||
renderAprsHistory();
|
||||
});
|
||||
}
|
||||
aprsWindow.onServerAprs = function(pkt) {
|
||||
function onServerAprs(pkt) {
|
||||
if (aprsStatus) aprsStatus.textContent = "Receiving";
|
||||
addAprsPacket(normalizeServerAprsPacket(pkt));
|
||||
};
|
||||
}
|
||||
renderAprsHistory();
|
||||
aprsWindow._trxDrainPendingDecode?.("aprs");
|
||||
window.trxPluginRuntime.registerDecoder({
|
||||
id: "aprs",
|
||||
onMessage: onServerAprs,
|
||||
onBatch: onServerAprsBatch,
|
||||
restore: onServerAprsBatch,
|
||||
reset: resetAprsHistoryView,
|
||||
prune: pruneAprsHistoryView
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user