summaryrefslogtreecommitdiff
path: root/packages/anastasis-webui
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-04-15 12:56:16 +0200
committerFlorian Dold <florian@dold.me>2022-04-15 12:56:16 +0200
commitd1b4cc994bd287af5c8a3114eab70ee01f92b4ec (patch)
treef0b3c36540bd8a8f6ecb3cdb359b18e97170fc5a /packages/anastasis-webui
parent098d1eb7ebfcd2d4b460758772d42367a61dc5b2 (diff)
downloadwallet-core-d1b4cc994bd287af5c8a3114eab70ee01f92b4ec.tar.gz
wallet-core-d1b4cc994bd287af5c8a3114eab70ee01f92b4ec.tar.bz2
wallet-core-d1b4cc994bd287af5c8a3114eab70ee01f92b4ec.zip
anastasis-core: async provider synchronization
Diffstat (limited to 'packages/anastasis-webui')
-rw-r--r--packages/anastasis-webui/src/hooks/use-anastasis-reducer.ts39
-rw-r--r--packages/anastasis-webui/src/pages/home/ContinentSelectionScreen.tsx1
2 files changed, 39 insertions, 1 deletions
diff --git a/packages/anastasis-webui/src/hooks/use-anastasis-reducer.ts b/packages/anastasis-webui/src/hooks/use-anastasis-reducer.ts
index 434e5fb09..1b77db38f 100644
--- a/packages/anastasis-webui/src/hooks/use-anastasis-reducer.ts
+++ b/packages/anastasis-webui/src/hooks/use-anastasis-reducer.ts
@@ -21,6 +21,7 @@ import { TalerErrorCode } from "@gnu-taler/taler-util";
import {
AggregatedPolicyMetaInfo,
BackupStates,
+ completeProviderStatus,
discoverPolicies,
DiscoveryCursor,
getBackupStartState,
@@ -206,6 +207,44 @@ export function useAnastasisReducer(): AnastasisReducerApi {
console.log(e);
}
setAnastasisStateInternal(newState);
+
+ const tryUpdateProviders = () => {
+ const reducerState = newState.reducerState;
+ if (
+ reducerState?.reducer_type !== "backup" &&
+ reducerState?.reducer_type !== "recovery"
+ ) {
+ return;
+ }
+ const provMap = reducerState.authentication_providers;
+ if (!provMap) {
+ return;
+ }
+ const doUpdate = async () => {
+ const updates = await completeProviderStatus(provMap);
+ if (Object.keys(updates).length === 0) {
+ return;
+ }
+ console.log("got provider updates", updates);
+ const rs2 = reducerState;
+ if (rs2.reducer_type !== "backup" && rs2.reducer_type !== "recovery") {
+ return;
+ }
+ setAnastasisState({
+ ...anastasisState,
+ reducerState: {
+ ...rs2,
+ authentication_providers: {
+ ...rs2.authentication_providers,
+ ...updates,
+ },
+ },
+ });
+ };
+ doUpdate().catch((e) => console.log(e));
+ };
+
+ tryUpdateProviders();
};
async function doTransition(action: string, args: any): Promise<void> {
diff --git a/packages/anastasis-webui/src/pages/home/ContinentSelectionScreen.tsx b/packages/anastasis-webui/src/pages/home/ContinentSelectionScreen.tsx
index 2a480de48..e5dbcd8fc 100644
--- a/packages/anastasis-webui/src/pages/home/ContinentSelectionScreen.tsx
+++ b/packages/anastasis-webui/src/pages/home/ContinentSelectionScreen.tsx
@@ -37,7 +37,6 @@ export function ContinentSelectionScreen(): VNode {
if (!theCountry) return;
reducer.transition("select_country", {
country_code: countryCode,
- currencies: [theCountry.currency],
});
};