diff options
Diffstat (limited to 'extension/src')
-rw-r--r-- | extension/src/features/auth-api.ts | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/extension/src/features/auth-api.ts b/extension/src/features/auth-api.ts index e3f6c21..f47d505 100644 --- a/extension/src/features/auth-api.ts +++ b/extension/src/features/auth-api.ts @@ -16,6 +16,7 @@ import { AxiosInstance } from "axios"; import { get } from "@vueuse/core"; import { computed } from "vue"; +import { delay } from "lodash"; import { usePkiAuth, useSession, useUser } from "@vnuge/vnlib.browser"; import type { ClientStatus } from "./types"; import type { AppSettings } from "./settings"; @@ -23,6 +24,7 @@ import type { JsonObject } from "type-fest"; import { type FeatureApi, type BgRuntime, type IFeatureExport, exportForegroundApi, popupAndOptionsOnly, popupOnly } from "./framework"; import { waitForChangeFn } from "./util"; + export interface ProectedHandler<T extends JsonObject> { (message: T): Promise<any> } @@ -46,7 +48,7 @@ export interface UserApi extends FeatureApi { export const useAuthApi = (): IFeatureExport<AppSettings, UserApi> => { return { - background: ({ state, onInstalled }:BgRuntime<AppSettings>): UserApi =>{ + background: ({ state }:BgRuntime<AppSettings>): UserApi =>{ const { loggedIn, clearLoginState } = useSession(); const { currentConfig } = state const { logout, getProfile, heartbeat, userName } = useUser(); @@ -74,14 +76,9 @@ export const useAuthApi = (): IFeatureExport<AppSettings, UserApi> => { } } - //Install hook for interval - onInstalled(() => { - //Configure interval to run every 5 minutes to update the status - setInterval(runHeartbeat, 60 * 1000); - //Run immediately - runHeartbeat(); - return Promise.resolve(); - }) + //Configure interval to run every 5 minutes to update the status + setInterval(runHeartbeat, 60 * 1000); + delay(runHeartbeat, 1000) //Delay 1 second to allow the extension to load return { waitForChange: waitForChangeFn([currentConfig, loggedIn, userName]), |