()
| 68 | // addListener for event-page wakeup). Any cold path reloads — addListener |
| 69 | // after a macrotask would miss the queued wakeup event. |
| 70 | export async function getWatchListCache() { |
| 71 | const cached = localStorage.getItem('mvelo.watchlist.cache'); |
| 72 | if (cached) { |
| 73 | return JSON.parse(cached); |
| 74 | } |
| 75 | // Cold path: ensure the cache is populated so the next init's warm path hits. |
| 76 | await defaultsInitialized; |
| 77 | if (!localStorage.getItem('mvelo.watchlist.cache')) { |
| 78 | const watchList = await mvelo.storage.get('mvelo.watchlist'); |
| 79 | if (watchList) { |
| 80 | localStorage.setItem('mvelo.watchlist.cache', JSON.stringify(watchList)); |
| 81 | } |
| 82 | } |
| 83 | window.location.reload(); |
| 84 | await new Promise(() => {}); // page is reloading |
| 85 | } |
| 86 | |
| 87 | export async function setWatchList(watchList) { |
| 88 | await mvelo.storage.set('mvelo.watchlist', watchList); |
no test coverage detected