diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/scheduler.js b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/scheduler.js index 21264d1..adee749 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/scheduler.js +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/scheduler.js @@ -106,9 +106,18 @@ } function apiGetBookmarks() { - return fetch("/bookmarks").then(function (r) { - if (!r.ok) throw new Error("HTTP " + r.status); - return r.json(); + // Fetch general bookmarks and rig-specific bookmarks, then merge. + // Rig-specific entries win on duplicate IDs. + 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); }); } diff --git a/src/trx-client/trx-frontend/trx-frontend-http/src/bookmarks.rs b/src/trx-client/trx-frontend/trx-frontend-http/src/bookmarks.rs index aaf9bc7..1a9c401 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/src/bookmarks.rs +++ b/src/trx-client/trx-frontend/trx-frontend-http/src/bookmarks.rs @@ -128,6 +128,12 @@ pub struct BookmarkStoreMap { rig_stores: Mutex>>, } +impl Default for BookmarkStoreMap { + fn default() -> Self { + Self::new() + } +} + impl BookmarkStoreMap { pub fn new() -> Self { let general_path = BookmarkStore::general_path();