diff options
Diffstat (limited to 'packages/aml-backoffice-ui/src/hooks/useOfficer.ts')
-rw-r--r-- | packages/aml-backoffice-ui/src/hooks/useOfficer.ts | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/packages/aml-backoffice-ui/src/hooks/useOfficer.ts b/packages/aml-backoffice-ui/src/hooks/useOfficer.ts index fe989f3eb..1bf2b308b 100644 --- a/packages/aml-backoffice-ui/src/hooks/useOfficer.ts +++ b/packages/aml-backoffice-ui/src/hooks/useOfficer.ts @@ -8,19 +8,17 @@ import { buildCodecForObject, codecForAbsoluteTime, codecForString, - codecOptional, createNewOfficerAccount, decodeCrock, encodeCrock, - unlockOfficerAccount, + unlockOfficerAccount } from "@gnu-taler/taler-util"; import { buildStorageKey, - useLocalStorage, - useMemoryStorage, + useLocalStorage } from "@gnu-taler/web-util/browser"; import { useMemo } from "preact/hooks"; -import { useExchangeApiContext, useMaybeExchangeApiContext } from "../context/config.js"; +import { useMaybeExchangeApiContext } from "../context/config.js"; export interface Officer { account: LockedAccount; @@ -66,7 +64,6 @@ interface OfficerReady { const OFFICER_KEY = buildStorageKey("officer", codecForOfficer()); const DEV_ACCOUNT_KEY = buildStorageKey("account-dev", codecForOfficerAccount()); -const ACCOUNT_KEY = "account"; export function useOfficer(): OfficerState { const exchangeContext = useMaybeExchangeApiContext(); @@ -74,18 +71,18 @@ export function useOfficer(): OfficerState { const accountStorage = useLocalStorage(DEV_ACCOUNT_KEY); const account = useMemo(() => { if (!accountStorage.value) return undefined + return { id: accountStorage.value.id as OfficerId, signingKey: decodeCrock(accountStorage.value.strKey) as SigningKey } - }, [accountStorage.value]) - - - // const accountStorage = useMemoryStorage<OfficerAccount>(ACCOUNT_KEY); - // const account = accountStorage.value; + }, [accountStorage.value?.id, accountStorage.value?.strKey]) const officerStorage = useLocalStorage(OFFICER_KEY); - const officer = officerStorage.value; + const officer = useMemo(() => { + if (!officerStorage.value) return undefined + return officerStorage.value + }, [officerStorage.value?.account, officerStorage.value?.when.t_ms]) if (officer === undefined) { return { |