diff options
Diffstat (limited to 'packages/anastasis-webui/src/hooks')
| -rw-r--r-- | packages/anastasis-webui/src/hooks/use-anastasis-reducer.ts | 39 | 
1 files changed, 39 insertions, 0 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> {  | 
