schoolbox web extension :)
0
fork

Configure Feed

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

fix: separate motd and updated into separate storage items

* close #262
* this partially resolves #265 but settings still reset when clicking on
the needs refresh button

willow 0f874eb4 d193dfe4

+30 -15
+3 -4
src/entrypoints/background.ts
··· 11 11 } else if (reason === "update") { 12 12 logger.info("[background] Showing update badge"); 13 13 14 - await globalSettings.set({ updated: true }); 14 + await updated.set(true); 15 15 updateIcon(); 16 16 17 17 if (import.meta.env.DEV) { ··· 108 108 109 109 async function updateIcon() { 110 110 logger.info("[background] Updating icon..."); 111 - const settingsValue = await globalSettings.storage.getValue(); 112 111 113 112 let iconSuffix = ""; 114 113 ··· 116 115 if (new Date().getMonth() === 5) { 117 116 iconSuffix += "-ctp"; 118 117 } 119 - if (settingsValue.global === false) { 118 + if ((await globalSettings.storage.getValue()).global === false) { 120 119 iconSuffix += "-disabled"; 121 120 } 122 - if (settingsValue.updated === true) { 121 + if ((await updated.storage.getValue()) === true) { 123 122 iconSuffix += "-badge"; 124 123 } 125 124
+1 -1
src/entrypoints/popup/components/Footer.svelte
··· 17 17 <span class="relative inline-flex"> 18 18 <Button 19 19 onclick={async () => { 20 - await globalSettings.set({ updated: false }); 20 + await updated.set(false); 21 21 22 22 browser.tabs.create({ 23 23 url: `https://github.com/schooltape/schooltape/releases/tag/v${version}`,
+2 -2
src/entrypoints/popup/components/Motd.svelte
··· 5 5 // update MOTD 6 6 const response = await fetch("https://schooltape.github.io/motd.txt"); 7 7 if (response.ok) { 8 - globalSettings.set({ motd: await response.text() }); 8 + motd.set({ motd: await response.text() }); 9 9 } 10 10 }); 11 11 </script> ··· 13 13 <!-- MOTD --> 14 14 <div class="text-ctp-subtext0 text-center italic"> 15 15 <!-- eslint-disable-next-line svelte/no-at-html-tags --> 16 - <p>{@html globalSettings.state.motd}</p> 16 + <p>{@html motd.state.motd}</p> 17 17 <!-- Free and <a href='https://github.com/schooltape/schooltape' class='text-(--ctp-accent)'> open source</a>! --> 18 18 </div>
+18 -4
src/utils/storage.ts
··· 11 11 themes: true, 12 12 snippets: true, 13 13 14 - updated: false, 15 - motd: "Free and <a href='https://github.com/schooltape/schooltape' class='text-(--ctp-accent)'> open source</a>!", 16 - userSnippets: {}, 17 - 18 14 themeFlavour: "mocha", 19 15 themeAccent: "mauve", 20 16 themeLogo: "schooltape-rainbow", 21 17 themeLogoAsFavicon: false, 18 + 19 + userSnippets: {}, 22 20 }, 23 21 migrations: { 24 22 2: (oldData) => { ··· 42 40 export const needsRefresh = new StorageState( 43 41 storage.defineItem<boolean>("local:needsRefresh", { 44 42 fallback: false, 43 + }), 44 + ); 45 + 46 + // whether schooltape was recently updated, displays a badge on the icon and renders an info box 47 + export const updated = new StorageState( 48 + storage.defineItem<boolean>("local:updated", { 49 + fallback: false, 50 + }), 51 + ); 52 + 53 + // message of the day 54 + export const motd = new StorageState( 55 + storage.defineItem<Types.Motd>("local:motd", { 56 + fallback: { 57 + motd: "Free and <a href='https://github.com/schooltape/schooltape' class='text-(--ctp-accent)'> open source</a>!", 58 + }, 45 59 }), 46 60 ); 47 61
+6 -4
src/utils/types.ts
··· 5 5 themes: boolean; 6 6 snippets: boolean; 7 7 8 - updated: boolean; // whether schooltape was recently updated, displays a badge on the icon and renders an info box 9 - motd: string; // message of the day 10 - userSnippets: Record<string, UserSnippet>; 11 - 12 8 themeFlavour: string; 13 9 themeAccent: string; 14 10 themeLogo: LogoId; 15 11 themeLogoAsFavicon: boolean; 12 + 13 + userSnippets: Record<string, UserSnippet>; 14 + } 15 + 16 + export interface Motd { 17 + motd: string; 16 18 } 17 19 18 20 export interface SchoolboxUrls {