diff options
author | vnugent <public@vaughnnugent.com> | 2023-12-27 14:14:01 -0500 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2023-12-27 14:14:01 -0500 |
commit | 316728f8164dd0245f75d5116072e5ffa3896355 (patch) | |
tree | b3b605ba77ae78be3de08a3f9f5e988bd535c2d5 /extension/src/features | |
parent | 54984ef915a3bf640e06015bd294bd2186b3a588 (diff) |
update readme roadmap & heartbeat timeout
Diffstat (limited to 'extension/src/features')
-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]), |