commit fb318bf5072e8c71629c7d72f2131a28489822c4
parent a9b1e425bba7023740ec2883f18fb9e636f48759
Author: Florian Dold <florian@dold.me>
Date: Tue, 3 Sep 2024 23:20:31 +0200
wallet-core: implement hintApplicationResumed
Diffstat:
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts
@@ -289,6 +289,7 @@ export enum WalletApiOperation {
TestingResetAllRetries = "testingResetAllRetries",
StartExchangeWalletKyc = "startExchangeWalletKyc",
TestingWaitExchangeWalletKyc = "testingWaitWalletKyc",
+ HintApplicationResumed = "hintApplicationResumed",
}
// group: Initialization
@@ -311,6 +312,17 @@ export type ShutdownOp = {
};
/**
+ * Give wallet-core a kick and restart all pending tasks.
+ * Useful when the host application gets suspended and resumed,
+ * and active network requests might have stalled.
+ */
+export type HintApplicationResumedOp = {
+ op: WalletApiOperation.HintApplicationResumed;
+ request: EmptyObject;
+ response: EmptyObject;
+};
+
+/**
* Change the configuration of wallet-core.
*
* Currently an alias for the initWallet request.
@@ -1398,6 +1410,7 @@ export type WalletOperations = {
[WalletApiOperation.GetBankingChoicesForPayto]: GetBankingChoicesForPaytoOp;
[WalletApiOperation.StartExchangeWalletKyc]: StartExchangeWalletKycOp;
[WalletApiOperation.TestingWaitExchangeWalletKyc]: TestingWaitExchangeWalletKycOp;
+ [WalletApiOperation.HintApplicationResumed]: HintApplicationResumedOp;
};
export type WalletCoreRequestType<
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
@@ -1530,6 +1530,15 @@ async function handleGetCurrencySpecification(
return defaultResp;
}
+export async function handleHintApplicationResumed(
+ wex: WalletExecutionContext,
+ req: EmptyObject,
+): Promise<EmptyObject> {
+ logger.info("handling hintApplicationResumed");
+ await restartAllRunningTasks(wex);
+ return {};
+}
+
async function handleGetVersion(
wex: WalletExecutionContext,
): Promise<WalletCoreVersion> {
@@ -1562,6 +1571,10 @@ const handlers: { [T in WalletApiOperation]: HandlerWithValidator<T> } = {
codec: codecForAny(),
handler: handleTestingWaitExchangeState,
},
+ [WalletApiOperation.HintApplicationResumed]: {
+ codec: codecForEmptyObject(),
+ handler: handleHintApplicationResumed,
+ },
[WalletApiOperation.AbortTransaction]: {
codec: codecForAbortTransaction(),
handler: handleAbortTransaction,