diff options
author | Sebastian <sebasjm@gmail.com> | 2023-04-07 17:30:01 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-04-07 17:30:01 -0300 |
commit | a3aa7d95d09c83794067c47df4a455c0e3f21806 (patch) | |
tree | 00837196305227fe6f7cbc7289f96b256d5de089 /packages/demobank-ui/src/context/pageState.ts | |
parent | 43ae414a55b84b1125c5e4377c6d485ca6c748e2 (diff) | |
download | wallet-core-a3aa7d95d09c83794067c47df4a455c0e3f21806.tar.xz |
anon withdrawal confirmation, and fix error with infinity loop
Diffstat (limited to 'packages/demobank-ui/src/context/pageState.ts')
-rw-r--r-- | packages/demobank-ui/src/context/pageState.ts | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/packages/demobank-ui/src/context/pageState.ts b/packages/demobank-ui/src/context/pageState.ts index 247297c7b..074fbcafc 100644 --- a/packages/demobank-ui/src/context/pageState.ts +++ b/packages/demobank-ui/src/context/pageState.ts @@ -29,9 +29,7 @@ export type Type = { pageStateSetter: StateUpdater<PageStateType>; }; const initial: Type = { - pageState: { - withdrawalInProgress: false, - }, + pageState: {}, pageStateSetter: () => { null; }, @@ -57,9 +55,7 @@ export const PageStateProvider = ({ * Wrapper providing defaults. */ function usePageState( - state: PageStateType = { - withdrawalInProgress: false, - }, + state: PageStateType = {}, ): [PageStateType, StateUpdater<PageStateType>] { const ret = useNotNullLocalStorage("page-state", JSON.stringify(state)); const retObj: PageStateType = JSON.parse(ret[0]); @@ -100,14 +96,18 @@ export type ErrorMessage = { * Track page state. */ export interface PageStateType { - error?: ErrorMessage; - info?: TranslatedString; - - withdrawalInProgress: boolean; - talerWithdrawUri?: string; - /** - * Not strictly a presentational value, could - * be moved in a future "withdrawal state" object. - */ - withdrawalId?: string; + currentWithdrawalOperationId?: string; +} + +export interface ObservedStateType { + error: ErrorMessage | undefined; + info: TranslatedString | undefined; +} +export const errorListeners: Array<(error: ErrorMessage) => void> = []; +export const infoListeners: Array<(info: TranslatedString) => void> = []; +export function notifyError(error: ErrorMessage) { + errorListeners.forEach((cb) => cb(error)); +} +export function notifyInfo(info: TranslatedString) { + infoListeners.forEach((cb) => cb(info)); } |