From f4811da294e37544fcf7b66e95c5c762174af762 Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Tue, 26 Sep 2023 11:39:34 +0200 Subject: [PATCH] dev(auth): lower token refresh interval in dev mode --- src/context/WalletContext.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/context/WalletContext.tsx b/src/context/WalletContext.tsx index 90f96c5d..1995160e 100644 --- a/src/context/WalletContext.tsx +++ b/src/context/WalletContext.tsx @@ -6,6 +6,11 @@ import * as Api from '../libs/JmWalletApi' import { WalletBalanceSummary, toBalanceSummary } from './BalanceSummary' import { JM_API_AUTH_TOKEN_EXPIRY } from '../constants/config' +import { isDevMode } from '../constants/debugFeatures' + +const API_AUTH_TOKEN_RENEW_INTERVAL: Milliseconds = isDevMode() + ? 60 * 1_000 + : Math.round(JM_API_AUTH_TOKEN_EXPIRY * 0.75) export interface CurrentWallet { name: Api.WalletName @@ -337,7 +342,7 @@ const WalletProvider = ({ children }: PropsWithChildren) => { .catch((err) => console.error(err)) } - const interval = setInterval(renewToken, JM_API_AUTH_TOKEN_EXPIRY / 3) + const interval = setInterval(renewToken, API_AUTH_TOKEN_RENEW_INTERVAL) return () => { clearInterval(interval) abortCtrl.abort()