schoolbox web extension :)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: v4 storage migration not including fallback

* urls not being stored correctly

willow c5a7b60d 92bf3d6b

+31 -10
+4 -2
src/entrypoints/end.content.ts
··· 4 4 excludeMatches: EXCLUDE_MATCHES, 5 5 async main() { 6 6 const settings = await globalSettings.storage.getValue(); 7 - const urls = await schoolboxUrls.storage.getValue(); 7 + const urls = (await schoolboxUrls.storage.getValue()).urls; 8 + 9 + console.log((await schoolboxUrls.storage.getValue()).urls); 8 10 9 11 if (!settings.global) return; 10 12 const footer = document.querySelector("#footer > ul"); ··· 20 22 logger.info("[end.content.ts] URL not in settings, adding..."); 21 23 if (!urls.includes(window.location.origin)) { 22 24 urls.push(window.location.origin); 23 - await schoolboxUrls.storage.setValue(urls); 25 + await schoolboxUrls.storage.setValue({ urls }); 24 26 // TODO: hot reload 25 27 window.location.reload(); 26 28 }
+1 -1
src/entrypoints/popup/App.svelte
··· 21 21 22 22 async function refreshSchoolboxURLs() { 23 23 logger.info("[App.svelte] Refreshing all Schoolbox URLs"); 24 - const urls = (await schoolboxUrls.storage.getValue()).map((url) => url.replace(/^https:\/\//, "*://") + "/*"); 24 + const urls = (await schoolboxUrls.storage.getValue()).urls.map((url) => url.replace(/^https:\/\//, "*://") + "/*"); 25 25 const tabs = await browser.tabs.query({ url: urls }); 26 26 tabs.forEach((tab) => { 27 27 if (tab.id) {
+1 -1
src/entrypoints/start.content.ts
··· 7 7 excludeMatches: EXCLUDE_MATCHES, 8 8 async main() { 9 9 const settings = await globalSettings.storage.getValue(); 10 - const urls = await schoolboxUrls.storage.getValue(); 10 + const urls = (await schoolboxUrls.storage.getValue()).urls; 11 11 12 12 if (settings.global && urls.includes(window.location.origin)) { 13 13 // inject themes
+1 -1
src/utils/plugin.ts
··· 8 8 logger.info(`${plugins[pluginId].info.name}: ${plugin.toggle ? "enabled" : "disabled"}`); 9 9 10 10 const settings = await globalSettings.storage.getValue(); 11 - const urls = await schoolboxUrls.storage.getValue(); 11 + const urls = (await schoolboxUrls.storage.getValue()).urls; 12 12 13 13 if (plugin && typeof window !== "undefined" && urls.includes(window.location.origin)) { 14 14 if (settings.global && settings.plugins && plugin.toggle) {
+1 -1
src/utils/snippet.ts
··· 4 4 logger.info(`${snippets[snippetId].info.name}: ${snippet.toggle ? "enabled" : "disabled"}`); 5 5 6 6 const settings = await globalSettings.storage.getValue(); 7 - const urls = await schoolboxUrls.storage.getValue(); 7 + const urls = (await schoolboxUrls.storage.getValue()).urls; 8 8 9 9 if (snippet && typeof window !== "undefined" && urls.includes(window.location.origin)) { 10 10 if (settings.global && settings.snippets && snippet.toggle) {
+19 -4
src/utils/storage.ts
··· 2 2 import { StorageState } from "./state.svelte"; 3 3 4 4 // Global 5 - export const globalSettings = new StorageState<Types.Settings>( 5 + export const globalSettings: StorageState<Types.Settings> = new StorageState<Types.Settings>( 6 6 storage.defineItem<Types.Settings>("local:globalSettings", { 7 - version: 2, 7 + version: 3, 8 8 fallback: { 9 9 global: true, 10 10 plugins: true, ··· 25 25 needsRefresh.set(oldData.needsRefresh); 26 26 schoolboxUrls.set(oldData.schoolboxUrls); 27 27 return { 28 + ...globalSettings.storage.fallback, 28 29 global: oldData.global, 29 30 }; 30 31 }, 32 + 3: (oldData) => { 33 + return { 34 + ...oldData, 35 + ...globalSettings.storage.fallback, 36 + }; 37 + }, 31 38 }, 32 39 }), 33 40 ); ··· 39 46 ); 40 47 41 48 export const schoolboxUrls = new StorageState( 42 - storage.defineItem<string[]>("local:urls", { 43 - fallback: ["https://help.schoolbox.com.au"], 49 + storage.defineItem<Types.SchoolboxUrls>("local:urls", { 50 + version: 2, 51 + fallback: { 52 + urls: ["https://help.schoolbox.com.au"], 53 + }, 54 + migrations: { 55 + 2: () => { 56 + return { urls: ["https://help.schoolbox.com.au"] }; 57 + }, 58 + }, 44 59 }), 45 60 ); 46 61
+4
src/utils/types.ts
··· 15 15 themeLogoAsFavicon: boolean; 16 16 } 17 17 18 + export interface SchoolboxUrls { 19 + urls: string[]; 20 + } 21 + 18 22 export type LogoId = "default" | "catppuccin" | "schoolbox" | "schooltape" | "schooltape-rainbow" | "schooltape-legacy"; 19 23 20 24 export interface LogoInfo {