multiple schedule suppport kinda
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { createLocalStore, debugStore } from 'chrome-extension-toolkit';
|
||||
|
||||
/**
|
||||
@@ -9,31 +8,11 @@ interface IExtensionStore {
|
||||
version: string;
|
||||
/** When was the last update */
|
||||
lastUpdate: number;
|
||||
/** A unique identifier generated for the current user in lieu of a userId */
|
||||
deviceId: string;
|
||||
}
|
||||
|
||||
interface Actions {
|
||||
getDeviceId(): Promise<string>;
|
||||
}
|
||||
export const extensionStore = createLocalStore<IExtensionStore>({
|
||||
version: chrome.runtime.getManifest().version,
|
||||
lastUpdate: Date.now(),
|
||||
});
|
||||
|
||||
export const ExtensionStore = createLocalStore<IExtensionStore, Actions>(
|
||||
{
|
||||
version: chrome.runtime.getManifest().version,
|
||||
lastUpdate: Date.now(),
|
||||
deviceId: '',
|
||||
},
|
||||
store => ({
|
||||
getDeviceId: async () => {
|
||||
const deviceId = await store.getDeviceId();
|
||||
if (deviceId) {
|
||||
return deviceId;
|
||||
}
|
||||
const newDeviceId = uuidv4();
|
||||
await store.setDeviceId(newDeviceId);
|
||||
return newDeviceId;
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
debugStore({ ExtensionStore });
|
||||
debugStore({ extensionStore });
|
||||
|
||||
Reference in New Issue
Block a user