forked from tahowallet/extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.ts
28 lines (26 loc) · 857 Bytes
/
background.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { browser, startMain } from "@tallyho/tally-background"
import {
FeatureFlags,
isEnabled,
RuntimeFlag,
} from "@tallyho/tally-background/features"
import { ONBOARDING_ROOT } from "@tallyho/tally-ui/pages/Onboarding/Tabbed/Routes"
browser.runtime.onInstalled.addListener((obj) => {
if (obj.reason === "install") {
const url = browser.runtime.getURL(ONBOARDING_ROOT)
browser.tabs.create({ url })
}
/**
* Runtime feature flags should be clean from Local Storage if the build has change and SWITCH_RUNTIME_FLAGS is off.
* If SWITCH_RUNTIME_FLAGS is on then it should keep the previous feature flags settings.
*/
if (
obj.reason === "update" &&
!isEnabled(FeatureFlags.SWITCH_RUNTIME_FLAGS)
) {
Object.keys(RuntimeFlag).forEach((flagName) =>
localStorage.removeItem(flagName),
)
}
})
startMain()