Skip to content

Commit

Permalink
Allow migrations on Safari
Browse files Browse the repository at this point in the history
They weren't working due to the lack of `chrome.management` APIs.

Fixes #56
  • Loading branch information
fregante committed Dec 19, 2020
1 parent da4fcab commit 4ebbc8a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {compressToEncodedURIComponent, decompressFromEncodedURIComponent} from '

async function shouldRunMigrations(): Promise<boolean> {
return new Promise(resolve => {
chrome.management.getSelf(({installType}) => {
const callback = (installType: string): void => {
// Always run migrations during development #25
if (installType === 'development') {
resolve(true);
Expand All @@ -18,7 +18,13 @@ async function shouldRunMigrations(): Promise<boolean> {

// If `onInstalled` isn't fired, then migrations should not be run
setTimeout(resolve, 500, false);
});
};

if (chrome.management?.getSelf) {
chrome.management.getSelf(({installType}) => callback(installType));
} else {
callback('unknown');
}
});
}

Expand Down

0 comments on commit 4ebbc8a

Please sign in to comment.