[fix](trx-frontend-http): add Default impl for BookmarkStoreMap, merge bookmarks in scheduler

Fix clippy warning by adding Default impl for BookmarkStoreMap. Scheduler
bookmark picker now fetches both general and rig-specific bookmarks and
merges them so all available bookmarks are shown.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
2026-03-24 20:26:55 +01:00
parent 55688a27b2
commit 55266bf83e
2 changed files with 18 additions and 3 deletions
@@ -106,9 +106,18 @@
} }
function apiGetBookmarks() { function apiGetBookmarks() {
return fetch("/bookmarks").then(function (r) { // Fetch general bookmarks and rig-specific bookmarks, then merge.
if (!r.ok) throw new Error("HTTP " + r.status); // Rig-specific entries win on duplicate IDs.
return r.json(); var urls = ["/bookmarks"];
if (currentRigId) urls.push("/bookmarks?scope=" + encodeURIComponent(currentRigId));
return Promise.all(urls.map(function (u) {
return fetch(u).then(function (r) { return r.ok ? r.json() : []; });
})).then(function (results) {
var byId = {};
results.forEach(function (list) {
(Array.isArray(list) ? list : []).forEach(function (bm) { byId[bm.id] = bm; });
});
return Object.values(byId);
}); });
} }
@@ -128,6 +128,12 @@ pub struct BookmarkStoreMap {
rig_stores: Mutex<HashMap<String, Arc<BookmarkStore>>>, rig_stores: Mutex<HashMap<String, Arc<BookmarkStore>>>,
} }
impl Default for BookmarkStoreMap {
fn default() -> Self {
Self::new()
}
}
impl BookmarkStoreMap { impl BookmarkStoreMap {
pub fn new() -> Self { pub fn new() -> Self {
let general_path = BookmarkStore::general_path(); let general_path = BookmarkStore::general_path();