[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: anastasis-webui: return promi
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: anastasis-webui: return promises in anastasis reducer hook |
Date: |
Thu, 04 Nov 2021 17:43:44 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new 4ebeb002 anastasis-webui: return promises in anastasis reducer hook
4ebeb002 is described below
commit 4ebeb00243598f7a0caf79ef405134b14f68400e
Author: Florian Dold <florian@dold.me>
AuthorDate: Thu Nov 4 17:43:24 2021 +0100
anastasis-webui: return promises in anastasis reducer hook
---
.../src/hooks/use-anastasis-reducer.ts | 66 ++++++++++++----------
1 file changed, 36 insertions(+), 30 deletions(-)
diff --git a/packages/anastasis-webui/src/hooks/use-anastasis-reducer.ts
b/packages/anastasis-webui/src/hooks/use-anastasis-reducer.ts
index 72594749..1ef28a16 100644
--- a/packages/anastasis-webui/src/hooks/use-anastasis-reducer.ts
+++ b/packages/anastasis-webui/src/hooks/use-anastasis-reducer.ts
@@ -1,5 +1,12 @@
import { TalerErrorCode } from "@gnu-taler/taler-util";
-import { BackupStates, getBackupStartState, getRecoveryStartState,
RecoveryStates, reduceAction, ReducerState } from "anastasis-core";
+import {
+ BackupStates,
+ getBackupStartState,
+ getRecoveryStartState,
+ RecoveryStates,
+ reduceAction,
+ ReducerState,
+} from "anastasis-core";
import { useState } from "preact/hooks";
const reducerBaseUrl = "http://localhost:5000/";
@@ -98,13 +105,15 @@ export interface AnastasisReducerApi {
startBackup: () => void;
startRecover: () => void;
reset: () => void;
- back: () => void;
- transition(action: string, args: any): void;
+ back: () => Promise<void>;
+ transition(action: string, args: any): Promise<void>;
/**
* Run multiple reducer steps in a transaction without
* affecting the UI-visible transition state in-between.
*/
- runTransaction(f: (h: ReducerTransactionHandle) => Promise<void>): void;
+ runTransaction(
+ f: (h: ReducerTransactionHandle) => Promise<void>,
+ ): Promise<void>;
}
function storageGet(key: string): string | null {
@@ -222,9 +231,9 @@ export function useAnastasisReducer(): AnastasisReducerApi {
}
},
transition(action: string, args: any) {
- doTransition(action, args);
+ return doTransition(action, args);
},
- back() {
+ async back() {
const reducerState = anastasisState.reducerState;
if (!reducerState) {
return;
@@ -239,7 +248,7 @@ export function useAnastasisReducer(): AnastasisReducerApi {
reducerState: undefined,
});
} else {
- doTransition("back", {});
+ await doTransition("back", {});
}
},
dismissError() {
@@ -252,30 +261,27 @@ export function useAnastasisReducer():
AnastasisReducerApi {
reducerState: undefined,
});
},
- runTransaction(f) {
- async function run() {
- const txHandle = new ReducerTxImpl(anastasisState.reducerState!);
- try {
- await f(txHandle);
- } catch (e) {
- console.log("exception during reducer transaction", e);
- }
- const s = txHandle.transactionState;
- console.log("transaction finished, new state", s);
- if (s.code !== undefined) {
- setAnastasisState({
- ...anastasisState,
- currentError: txHandle.transactionState,
- });
- } else {
- setAnastasisState({
- ...anastasisState,
- reducerState: txHandle.transactionState,
- currentError: undefined,
- });
- }
+ async runTransaction(f) {
+ const txHandle = new ReducerTxImpl(anastasisState.reducerState!);
+ try {
+ await f(txHandle);
+ } catch (e) {
+ console.log("exception during reducer transaction", e);
+ }
+ const s = txHandle.transactionState;
+ console.log("transaction finished, new state", s);
+ if (s.code !== undefined) {
+ setAnastasisState({
+ ...anastasisState,
+ currentError: txHandle.transactionState,
+ });
+ } else {
+ setAnastasisState({
+ ...anastasisState,
+ reducerState: txHandle.transactionState,
+ currentError: undefined,
+ });
}
- run();
},
};
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: anastasis-webui: return promises in anastasis reducer hook,
gnunet <=