schoolbox web extension :)
0
fork

Configure Feed

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

feat: remove update badge after opening popup

- close #277

willow aca4eb38 0a551c6b

+28 -7
+3 -2
src/entrypoints/background.ts
··· 13 13 } else if (reason === "update") { 14 14 logger.info("[background] Showing update badge"); 15 15 16 - await updated.storage.setValue(true); 16 + await updated.set({ icon: true, changelog: true }); 17 17 updateIcon(); 18 18 19 19 const manifest = browser.runtime.getManifest(); ··· 22 22 // hacky way of resetting the extension to fix migration issues 23 23 // new version is greater than or equal to v4.0.5 AND previous version was less than v4.0.5 24 24 if (previousVersion && semver.gte(newVersion, "4.0.5") && semver.lt(previousVersion, "4.0.5")) { 25 + logger.info("[background] Clearing storage (v4.0.5 migration)"); 25 26 await storage.clear("local"); 26 27 } 27 28 ··· 129 130 if ((await globalSettings.storage.getValue()).global === false) { 130 131 iconSuffix += "-disabled"; 131 132 } 132 - if ((await updated.storage.getValue()) === true) { 133 + if ((await updated.storage.getValue()).icon === true) { 133 134 iconSuffix += "-badge"; 134 135 } 135 136
+5
src/entrypoints/popup/App.svelte
··· 37 37 } 38 38 39 39 let accentRgb = $derived(getAccentRgb(globalSettings.state.themeAccent, globalSettings.state.themeFlavour)); 40 + 41 + onMount(() => { 42 + updated.set({ icon: false }); 43 + browser.runtime.sendMessage({ updateIcon: true }); 44 + }); 40 45 </script> 41 46 42 47 <main
+2 -2
src/entrypoints/popup/components/Footer.svelte
··· 17 17 <span class="relative inline-flex"> 18 18 <Button 19 19 onclick={async () => { 20 - await updated.storage.setValue(false); 20 + await updated.set({ changelog: false }); 21 21 22 22 browser.tabs.create({ 23 23 url: `https://github.com/schooltape/schooltape/releases/tag/v${version}`, ··· 28 28 classList="text-ctp-subtext0 hover:bg-ctp-surface1"> 29 29 <GitBranch size={18} /> v{version} 30 30 <!-- show ripple badge if the extension has been updated (unread release notes) --> 31 - {#if updated.state} 31 + {#if updated.state.changelog} 32 32 <span class="absolute top-0 right-0 -mt-1 -mr-1 flex size-3"> 33 33 <span class="absolute inline-flex h-full w-full animate-ping rounded-full bg-ctp-blue opacity-75"></span> 34 34 <span class="relative inline-flex size-3 rounded-full bg-ctp-blue"></span>
+13 -3
src/utils/storage.ts
··· 26 26 }), 27 27 ); 28 28 29 - // whether schooltape was recently updated, displays a badge on the icon and renders an info box 29 + // whether schooltape was recently updated 30 30 export const updated = new StorageState( 31 - storage.defineItem<boolean>("local:updated", { 32 - fallback: false, 31 + storage.defineItem<Types.UpdatedBadges>("local:updated", { 32 + version: 2, 33 + fallback: { 34 + icon: false, 35 + changelog: false, 36 + }, 37 + migrations: { 38 + 2: async () => { 39 + // reset to fallback 40 + await storage.removeItem("local:updated"); 41 + }, 42 + }, 33 43 }), 34 44 ); 35 45
+5
src/utils/types.ts
··· 13 13 userSnippets: Record<string, UserSnippet>; 14 14 } 15 15 16 + export interface UpdatedBadges { 17 + icon: boolean; 18 + changelog: boolean; 19 + } 20 + 16 21 export interface Motd { 17 22 motd: string; 18 23 }