From 6b35748f25e0fae7acac2a8906880527bb577c3c Mon Sep 17 00:00:00 2001 From: James Date: Thu, 21 Jul 2022 02:31:55 +1200 Subject: [PATCH] feat(popup): :children_crossing: add extension update alert (#62) Squashed commit of the following: commit 3b9137c7ad8215467f58c19b692082f82c0790eb Author: James Date: Thu Jul 21 02:10:24 2022 +1200 feat(popup): :children_crossing: add 'what's new' alert commit 135ef418bb45dd592c8acc6417e3d3ebbb045395 Author: James Date: Thu Jul 21 02:02:38 2022 +1200 feat(storage): :card_file_box: add storage key for last update version --- src/apis/storage.ts | 9 +++++++++ src/popup/popup.ts | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/apis/storage.ts b/src/apis/storage.ts index 7734e104..60270fcd 100644 --- a/src/apis/storage.ts +++ b/src/apis/storage.ts @@ -10,9 +10,18 @@ const KEYS = { course: 'savedCourse', assignments: 'savedAssignments', oauthState: 'oauthState', + lastVersion: 'lastVersion', }; export const Storage = { + async getLastVersion(): Promise { + return (await browser.storage.local.get(KEYS.lastVersion))[KEYS.lastVersion]; + }, + + async setLastVersion(version: string) { + return await browser.storage.local.set({ [KEYS.lastVersion]: version }); + }, + async getOAuthState(): Promise { return (await browser.storage.local.get(KEYS.oauthState))[KEYS.oauthState]; }, diff --git a/src/popup/popup.ts b/src/popup/popup.ts index c0fe4a52..6b870c51 100644 --- a/src/popup/popup.ts +++ b/src/popup/popup.ts @@ -282,4 +282,15 @@ Storage.getStorageKey('notion.propertyNames.status', false).then(value => { if (!deleteProperty) return; Storage.clearStorageKey('notion.propertyNames.status'); +}); + +// * what's new alert +Storage.getLastVersion().then(version => { + const { version: manifestVersion } = browser.runtime.getManifest(); + + if (version === manifestVersion) return; + + alert(`Your extension has been updated to v${manifestVersion}!\n\nTo see what's new, visit the store page, the Discord Server, or the GitHub Repository.`); + + Storage.setLastVersion(manifestVersion); }); \ No newline at end of file