diff --git a/src/components/SetupErrorDisplay.tsx b/src/components/SetupErrorDisplay.tsx index 102bcd17..4763322e 100644 --- a/src/components/SetupErrorDisplay.tsx +++ b/src/components/SetupErrorDisplay.tsx @@ -33,7 +33,10 @@ function ErrorFooter() { ); } -export function SetupErrorDisplay(props: { initialError: Error }) { +export function SetupErrorDisplay(props: { + initialError: Error; + password?: string; +}) { // Error shouldn't be reactive, so we assign to it so it just gets rendered with the first value const i18n = useI18n(); const error = props.initialError; @@ -41,10 +44,9 @@ export function SetupErrorDisplay(props: { initialError: Error }) { const [lockSeconds, { mutate }] = createResource(async () => { if (error.message.startsWith("Mutiny is already running")) { const settings: MutinyWalletSettingStrings = await getSettings(); - // todo set password try { const secs = await MutinyWallet.get_device_lock_remaining_secs( - undefined, + props.password, settings.auth, settings.storage ); diff --git a/src/router.tsx b/src/router.tsx index bf64efe9..6111c5f4 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -85,7 +85,10 @@ export function Router() { return ( <Switch> <Match when={state.setup_error}> - <SetupErrorDisplay initialError={state.setup_error!} /> + <SetupErrorDisplay + initialError={state.setup_error!} + password={state.password} + /> </Match> <Match when={true}> <GlobalListeners /> diff --git a/src/state/megaStore.tsx b/src/state/megaStore.tsx index 39d8dc03..3a2ce105 100644 --- a/src/state/megaStore.tsx +++ b/src/state/megaStore.tsx @@ -61,6 +61,7 @@ export type MegaStore = [ subscription_timestamp?: number; readonly mutiny_plus: boolean; needs_password: boolean; + password?: string; load_stage: LoadStage; settings?: MutinyWalletSettingStrings; safe_mode?: boolean; @@ -122,6 +123,8 @@ export const Provider: ParentComponent = (props) => { return subscriptionValid(state.subscription_timestamp); }, needs_password: false, + // If setup fails we can remember the password for checking the device lock + password: undefined as string | undefined, load_stage: "fresh" as LoadStage, settings: undefined as MutinyWalletSettingStrings | undefined, safe_mode: searchParams.safe_mode === "true", @@ -218,7 +221,8 @@ export const Provider: ParentComponent = (props) => { if (eify(e).message === "Incorrect password entered.") { setState({ needs_password: true }); } else { - setState({ setup_error: eify(e) }); + // We only save the password for checking the timelock, will be blown away by the reload + setState({ setup_error: eify(e), password: password }); } } },