diff options
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)); } |