From 5ea22a325c069fe497b2dc8a73d4de69fd8cc27b Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 14 Apr 2023 14:07:15 -0300 Subject: using new localStorage api, pageState => settings, notifcation using observer api --- packages/demobank-ui/src/pages/HomePage.tsx | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'packages/demobank-ui/src/pages/HomePage.tsx') diff --git a/packages/demobank-ui/src/pages/HomePage.tsx b/packages/demobank-ui/src/pages/HomePage.tsx index 2cdbc49bc..340181a4f 100644 --- a/packages/demobank-ui/src/pages/HomePage.tsx +++ b/packages/demobank-ui/src/pages/HomePage.tsx @@ -27,17 +27,11 @@ import { useTranslationContext, } from "@gnu-taler/web-util/lib/index.browser"; import { Fragment, VNode, h } from "preact"; -import { StateUpdater } from "preact/hooks"; import { Loading } from "../components/Loading.js"; import { useBackendContext } from "../context/backend.js"; -import { - ObservedStateType, - PageStateType, - notifyError, - notifyInfo, - usePageContext, -} from "../context/pageState.js"; import { getInitialBackendBaseURL } from "../hooks/backend.js"; +import { notifyError, notifyInfo } from "../hooks/notification.js"; +import { useSettings } from "../hooks/settings.js"; import { AccountPage } from "./AccountPage.js"; import { AdminPage } from "./AdminPage.js"; import { LoginForm } from "./LoginForm.js"; @@ -63,15 +57,15 @@ export function HomePage({ onRegister: () => void; }): VNode { const backend = useBackendContext(); - const { pageState, pageStateSetter } = usePageContext(); + const [settings] = useSettings(); const { i18n } = useTranslationContext(); if (backend.state.status === "loggedOut") { return ; } - if (pageState.currentWithdrawalOperationId) { - onPendingOperationFound(pageState.currentWithdrawalOperationId); + if (settings.currentWithdrawalOperationId) { + onPendingOperationFound(settings.currentWithdrawalOperationId); return ; } @@ -104,9 +98,10 @@ export function WithdrawalOperationPage({ }); const parsedUri = parseWithdrawUri(uri); const { i18n } = useTranslationContext(); - const { pageStateSetter } = usePageContext(); + + const [settings, updateSettings] = useSettings(); function clearCurrentWithdrawal(): void { - pageStateSetter({}); + updateSettings("currentWithdrawalOperationId", undefined); onAbort(); } -- cgit v1.2.3