diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/background-decode.js b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/background-decode.js index 5318fd1..1d1872a 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/background-decode.js +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/background-decode.js @@ -111,11 +111,16 @@ function bookmarkDecoderKinds(bookmark) { const decoders = Array.isArray(bookmark && bookmark.decoders) ? bookmark.decoders : []; - return decoders + const supported = decoders .map(function (item) { return String(item || "").trim().toLowerCase(); }) .filter(function (item, index, arr) { return SUPPORTED_DECODERS.includes(item) && arr.indexOf(item) === index; }); + if (supported.length > 0) return supported; + const mode = String(bookmark && bookmark.mode || "").trim().toUpperCase(); + if (mode === "AIS") return ["ais"]; + if (mode === "PKT") return ["aprs"]; + return supported; } function renderBookmarkPick() { diff --git a/src/trx-client/trx-frontend/trx-frontend-http/src/background_decode.rs b/src/trx-client/trx-frontend/trx-frontend-http/src/background_decode.rs index 7d6eada..6e9f5e1 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/src/background_decode.rs +++ b/src/trx-client/trx-frontend/trx-frontend-http/src/background_decode.rs @@ -210,7 +210,7 @@ impl BackgroundDecodeManager { freq_hz: bookmark.map(|item| item.freq_hz), mode: bookmark.map(|item| item.mode.clone()), decoder_kinds: bookmark - .map(|item| supported_decoder_kinds(&item.decoders)) + .map(bookmark_supported_decoder_kinds) .unwrap_or_default(), state: "inactive".to_string(), channel_kind: None, @@ -345,7 +345,7 @@ impl BackgroundDecodeManager { continue; }; - let decoder_kinds = supported_decoder_kinds(&bookmark.decoders); + let decoder_kinds = bookmark_supported_decoder_kinds(bookmark); let mut status = BackgroundDecodeBookmarkStatus { bookmark_id: bookmark.id.clone(), bookmark_name: Some(bookmark.name.clone()), @@ -525,6 +525,19 @@ fn supported_decoder_kinds(decoders: &[String]) -> Vec { out } +fn bookmark_supported_decoder_kinds(bookmark: &Bookmark) -> Vec { + let explicit = supported_decoder_kinds(&bookmark.decoders); + if !explicit.is_empty() { + return explicit; + } + + match bookmark.mode.trim().to_ascii_uppercase().as_str() { + "AIS" => vec!["ais".to_string()], + "PKT" => vec!["aprs".to_string()], + _ => Vec::new(), + } +} + fn channel_matches_bookmark(channel: &ClientChannel, bookmark: &Bookmark) -> bool { channel.freq_hz == bookmark.freq_hz && normalized_mode(&channel.mode) == normalized_mode(&bookmark.mode) }