Skip to content

Commit

Permalink
bugfix: only listener code on extension install (#24)
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Erichsen <patrick.a.erichsen@gmail.com>
  • Loading branch information
Patrick-Erichsen authored Nov 2, 2021
1 parent 6163d7b commit 79832d7
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,24 @@ chrome.tabs.onUpdated.addListener((tabId, { url }) => {
}
});

chrome.runtime.onInstalled.addListener(() => {
const environment = process.env.NODE_ENV;

if (!environment) {
rollbar.error(`Failed to find NODE_ENV env var!`);
return;
}

if (process.env.NODE_ENV === 'production') {
chrome.runtime.setUninstallURL('https://offie.co/uninstall');

chrome.tabs.create({
url: 'https://offie.co/welcome',
active: true,
});
chrome.runtime.onInstalled.addListener((details) => {
// @ts-ignore
if (details.reason === chrome.runtime.OnInstalledReason.INSTALL) {
const environment = process.env.NODE_ENV;

if (!environment) {
rollbar.error(`Failed to find NODE_ENV env var!`);
return;
}

if (process.env.NODE_ENV === 'production') {
chrome.runtime.setUninstallURL('https://offie.co/uninstall');

chrome.tabs.create({
url: 'https://offie.co/welcome',
active: true,
});
}
}
});

Expand Down

0 comments on commit 79832d7

Please # to comment.