remove listener on unload
This commit is contained in:
parent
ff49e3477e
commit
78b056a0b1
@ -36,9 +36,12 @@ export function PendingTransactions({ goToTransaction }: Props): VNode {
|
|||||||
const state = useAsyncAsHook(wxApi.getTransactions);
|
const state = useAsyncAsHook(wxApi.getTransactions);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
wxApi.onUpdateNotification([NotificationType.WithdrawGroupFinished], () => {
|
return wxApi.onUpdateNotification(
|
||||||
state?.retry();
|
[NotificationType.WithdrawGroupFinished],
|
||||||
});
|
() => {
|
||||||
|
state?.retry();
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const transactions =
|
const transactions =
|
||||||
|
@ -44,9 +44,12 @@ export function BalancePage({
|
|||||||
const state = useAsyncAsHook(wxApi.getBalance);
|
const state = useAsyncAsHook(wxApi.getBalance);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
wxApi.onUpdateNotification([NotificationType.WithdrawGroupFinished], () => {
|
return wxApi.onUpdateNotification(
|
||||||
state?.retry();
|
[NotificationType.WithdrawGroupFinished],
|
||||||
});
|
() => {
|
||||||
|
state?.retry();
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const balances = !state || state.hasError ? [] : state.response.balances;
|
const balances = !state || state.hasError ? [] : state.response.balances;
|
||||||
|
@ -54,7 +54,7 @@ export function DeveloperPage(): VNode {
|
|||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
wxApi.onUpdateNotification(listenAllEvents, () => {
|
return wxApi.onUpdateNotification(listenAllEvents, () => {
|
||||||
response?.retry();
|
response?.retry();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -56,9 +56,12 @@ export function HistoryPage({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
wxApi.onUpdateNotification([NotificationType.WithdrawGroupFinished], () => {
|
return wxApi.onUpdateNotification(
|
||||||
state?.retry();
|
[NotificationType.WithdrawGroupFinished],
|
||||||
});
|
() => {
|
||||||
|
state?.retry();
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!state) {
|
if (!state) {
|
||||||
|
@ -52,7 +52,7 @@ export function ManualWithdrawPage({ currency, onCancel }: Props): VNode {
|
|||||||
|
|
||||||
const state = useAsyncAsHook(wxApi.listExchanges);
|
const state = useAsyncAsHook(wxApi.listExchanges);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
wxApi.onUpdateNotification([NotificationType.ExchangeAdded], () => {
|
return wxApi.onUpdateNotification([NotificationType.ExchangeAdded], () => {
|
||||||
state?.retry();
|
state?.retry();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -84,9 +84,12 @@ export function TransactionPage({ tid, goToWalletHistory }: Props): VNode {
|
|||||||
const state = useAsyncAsHook(() => getTransaction(tid), [tid]);
|
const state = useAsyncAsHook(() => getTransaction(tid), [tid]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
wxApi.onUpdateNotification([NotificationType.WithdrawGroupFinished], () => {
|
return wxApi.onUpdateNotification(
|
||||||
state?.retry();
|
[NotificationType.WithdrawGroupFinished],
|
||||||
});
|
() => {
|
||||||
|
state?.retry();
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!state) {
|
if (!state) {
|
||||||
|
@ -42,6 +42,7 @@ import {
|
|||||||
GetFeeForDepositRequest,
|
GetFeeForDepositRequest,
|
||||||
GetWithdrawalDetailsForUriRequest,
|
GetWithdrawalDetailsForUriRequest,
|
||||||
KnownBankAccounts,
|
KnownBankAccounts,
|
||||||
|
Logger,
|
||||||
NotificationType,
|
NotificationType,
|
||||||
PrepareDepositRequest,
|
PrepareDepositRequest,
|
||||||
PrepareDepositResponse,
|
PrepareDepositResponse,
|
||||||
@ -76,6 +77,7 @@ import { platform, MessageFromBackend } from "./platform/api.js";
|
|||||||
export interface ExtendedPermissionsResponse {
|
export interface ExtendedPermissionsResponse {
|
||||||
newValue: boolean;
|
newValue: boolean;
|
||||||
}
|
}
|
||||||
|
const logger = new Logger("wxApi");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Response with information about available version upgrades.
|
* Response with information about available version upgrades.
|
||||||
@ -106,7 +108,7 @@ async function callBackend(operation: string, payload: any): Promise<any> {
|
|||||||
console.log("Error calling backend");
|
console.log("Error calling backend");
|
||||||
throw new Error(`Error contacting backend: ${e}`);
|
throw new Error(`Error contacting backend: ${e}`);
|
||||||
}
|
}
|
||||||
console.log("got response", response);
|
logger.info("got response", response);
|
||||||
if (response.type === "error") {
|
if (response.type === "error") {
|
||||||
throw TalerError.fromUncheckedDetail(response.error);
|
throw TalerError.fromUncheckedDetail(response.error);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user