added deviceId, ExtensionStore, working on CoursePopup
This commit is contained in:
@@ -1,26 +1,9 @@
|
||||
import { SECOND } from 'src/shared/util/time';
|
||||
import { ExtensionStore } from '../storage/ExtensionStore';
|
||||
|
||||
/**
|
||||
* Called when the extension is first installed or synced onto a new machine
|
||||
*/
|
||||
export default async function onInstall() {
|
||||
// set the uninstall url
|
||||
chrome.runtime.setUninstallURL('https://www.google.com');
|
||||
logOnInstallEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* making sure we are not sending duplicate install event for users that have synced browsers
|
||||
* sync storage get's cleared on browser uninstall, so re-installing the browser will trigger the event
|
||||
*/
|
||||
function logOnInstallEvent() {
|
||||
setTimeout(async () => {
|
||||
const manifest = chrome.runtime.getManifest();
|
||||
const INSTALL_KEY = `${manifest.short_name}-installed`;
|
||||
const storage = await chrome.storage.sync.get(INSTALL_KEY);
|
||||
if (!storage[INSTALL_KEY]) {
|
||||
// TODO: send install event
|
||||
await chrome.storage.sync.set({ [INSTALL_KEY]: true });
|
||||
}
|
||||
}, 5 * SECOND);
|
||||
await ExtensionStore.setVersion(chrome.runtime.getManifest().version);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
import { hotReloadTab } from 'src/background/util/hotReloadTab';
|
||||
import { ExtensionStore } from '../storage/ExtensionStore';
|
||||
|
||||
/**
|
||||
* Called when the extension is updated (or when the extension is reloaded in development mode)
|
||||
*/
|
||||
export default function onUpdate() {
|
||||
export default async function onUpdate() {
|
||||
await Promise.all([
|
||||
ExtensionStore.setLastUpdate(Date.now()),
|
||||
ExtensionStore.setVersion(chrome.runtime.getManifest().version),
|
||||
]);
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
hotReloadTab();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user