Skip to content

Commit

Permalink
feat(popup): 🚸 add extension update alert (#62)
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 3b9137c
Author: James <james@jamesnzl.xyz>
Date:   Thu Jul 21 02:10:24 2022 +1200

    feat(popup): :children_crossing: add 'what's new' alert

commit 135ef41
Author: James <james@jamesnzl.xyz>
Date:   Thu Jul 21 02:02:38 2022 +1200

    feat(storage): :card_file_box: add storage key for last update version
  • Loading branch information
JamesNZL committed Jul 20, 2022
1 parent d5fd03a commit 6b35748
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/apis/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,18 @@ const KEYS = <const>{
course: 'savedCourse',
assignments: 'savedAssignments',
oauthState: 'oauthState',
lastVersion: 'lastVersion',
};

export const Storage = <const>{
async getLastVersion(): Promise<string> {
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<string> {
return (await browser.storage.local.get(KEYS.oauthState))[KEYS.oauthState];
},
Expand Down
11 changes: 11 additions & 0 deletions src/popup/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit 6b35748

Please sign in to comment.