diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/components')
4 files changed, 12 insertions, 11 deletions
diff --git a/packages/taler-wallet-webextension/src/components/PendingTransactions.tsx b/packages/taler-wallet-webextension/src/components/PendingTransactions.tsx index 5d5dae092..85b43fb4e 100644 --- a/packages/taler-wallet-webextension/src/components/PendingTransactions.tsx +++ b/packages/taler-wallet-webextension/src/components/PendingTransactions.tsx @@ -22,11 +22,11 @@ import { import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { Fragment, h, JSX, VNode } from "preact"; import { useEffect } from "preact/hooks"; +import { useBackendContext } from "../context/backend.js"; import { useTranslationContext } from "../context/translation.js"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; import { Avatar } from "../mui/Avatar.js"; import { Typography } from "../mui/Typography.js"; -import { wxApi } from "../wxApi.js"; import Banner from "./Banner.js"; import { Time } from "./Time.js"; @@ -35,12 +35,13 @@ interface Props extends JSX.HTMLAttributes { } export function PendingTransactions({ goToTransaction }: Props): VNode { + const api = useBackendContext(); const state = useAsyncAsHook(() => - wxApi.wallet.call(WalletApiOperation.GetTransactions, {}), + api.wallet.call(WalletApiOperation.GetTransactions, {}), ); useEffect(() => { - return wxApi.listener.onUpdateNotification( + return api.listener.onUpdateNotification( [NotificationType.WithdrawGroupFinished], state?.retry, ); diff --git a/packages/taler-wallet-webextension/src/components/ShowFullContractTermPopup.tsx b/packages/taler-wallet-webextension/src/components/ShowFullContractTermPopup.tsx index 6461f76e3..47c10347c 100644 --- a/packages/taler-wallet-webextension/src/components/ShowFullContractTermPopup.tsx +++ b/packages/taler-wallet-webextension/src/components/ShowFullContractTermPopup.tsx @@ -25,11 +25,11 @@ import { Loading } from "../components/Loading.js"; import { LoadingError } from "../components/LoadingError.js"; import { Modal } from "../components/Modal.js"; import { Time } from "../components/Time.js"; +import { useBackendContext } from "../context/backend.js"; import { useTranslationContext } from "../context/translation.js"; import { HookError, useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; import { ButtonHandler } from "../mui/handlers.js"; import { compose, StateViewMap } from "../utils/index.js"; -import { wxApi } from "../wxApi.js"; import { Amount } from "./Amount.js"; import { Link } from "./styled/index.js"; @@ -98,7 +98,8 @@ interface Props { proposalId: string; } -function useComponentState({ proposalId }: Props, api: typeof wxApi): State { +function useComponentState({ proposalId }: Props): State { + const api = useBackendContext(); const [show, setShow] = useState(false); const hook = useAsyncAsHook(async () => { if (!show) return undefined; @@ -139,7 +140,7 @@ const viewMapping: StateViewMap<State> = { export const ShowFullContractTermPopup = compose( "ShowFullContractTermPopup", - (p: Props) => useComponentState(p, wxApi), + (p: Props) => useComponentState(p), viewMapping, ); diff --git a/packages/taler-wallet-webextension/src/components/TermsOfService/index.ts b/packages/taler-wallet-webextension/src/components/TermsOfService/index.ts index 4d2c4346e..5d5ad3ba2 100644 --- a/packages/taler-wallet-webextension/src/components/TermsOfService/index.ts +++ b/packages/taler-wallet-webextension/src/components/TermsOfService/index.ts @@ -18,7 +18,6 @@ import { Loading } from "../../components/Loading.js"; import { HookError } from "../../hooks/useAsyncAsHook.js"; import { ToggleHandler } from "../../mui/handlers.js"; import { compose, StateViewMap } from "../../utils/index.js"; -import { wxApi } from "../../wxApi.js"; import { useComponentState } from "./state.js"; import { TermsState } from "./utils.js"; import { @@ -26,7 +25,7 @@ import { LoadingUriView, ShowButtonsAcceptedTosView, ShowButtonsNonAcceptedTosView, - ShowTosContentView, + ShowTosContentView } from "./views.js"; export interface Props { @@ -89,6 +88,6 @@ const viewMapping: StateViewMap<State> = { export const TermsOfService = compose( "TermsOfService", - (p: Props) => useComponentState(p, wxApi), + (p: Props) => useComponentState(p), viewMapping, ); diff --git a/packages/taler-wallet-webextension/src/components/TermsOfService/state.ts b/packages/taler-wallet-webextension/src/components/TermsOfService/state.ts index c5be71ef0..5006cefce 100644 --- a/packages/taler-wallet-webextension/src/components/TermsOfService/state.ts +++ b/packages/taler-wallet-webextension/src/components/TermsOfService/state.ts @@ -16,15 +16,15 @@ import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { useState } from "preact/hooks"; +import { useBackendContext } from "../../context/backend.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; -import { wxApi } from "../../wxApi.js"; import { Props, State } from "./index.js"; import { buildTermsOfServiceState } from "./utils.js"; export function useComponentState( { exchangeUrl, onChange }: Props, - api: typeof wxApi, ): State { + const api = useBackendContext() const readOnly = !onChange; const [showContent, setShowContent] = useState<boolean>(readOnly); const [errorAccepting, setErrorAccepting] = useState<Error | undefined>( |