web: fix page state persistence on account recovery pages

This commit is contained in:
Abdullah Atta
2026-02-16 15:16:20 +05:00
parent fe143f66b7
commit 09e5d014df
3 changed files with 17 additions and 9 deletions

View File

@@ -116,9 +116,12 @@ const sessionExpiryExceptions: Routes[] = [
];
function getRoute(): RouteWithPath<AuthProps> | RouteWithPath {
const path = getCurrentPath() as Routes;
let path = getCurrentPath() as Routes;
// logger.info(`Getting route for path: ${path}`);
const isAccountRecovery = isAccountRecoveryRoute(path);
if (isAccountRecovery) path = "/account/recovery";
const signup = redirectToRegistration(path);
const sessionExpired = isSessionExpired(path);
const fallback = fallbackRoute();
@@ -135,6 +138,10 @@ function getRoute(): RouteWithPath<AuthProps> | RouteWithPath {
return signup || sessionExpired || route || fallback;
}
function isAccountRecoveryRoute(path: Routes): boolean {
return path.startsWith("/account/recovery");
}
function fallbackRoute(): RouteWithPath {
return { route: routes.default, path: "default" };
}
@@ -187,7 +194,13 @@ export async function init() {
initializeLogger()
]);
return { Component, path, props: route.props };
const persistence =
(path !== "/sessionexpired" && isAccountRecoveryRoute(path)) ||
Config.get("sessionExpired", false)
? ("db" as const)
: ("memory" as const);
return { Component, path, props: route.props, persistence };
}
function shouldSkipInitiation() {

View File

@@ -27,7 +27,6 @@ import {
} from "./components/error-boundary";
import { desktop } from "./common/desktop-bridge";
import { useKeyStore } from "./interfaces/key-store";
import Config from "./utils/config";
import { usePromise } from "@notesnook/common";
import { AuthProps } from "./views/auth";
import { loadDatabase } from "./hooks/use-database";
@@ -52,13 +51,8 @@ export async function startApp(children?: React.ReactNode) {
: await import("./components/title-bar").then((m) => m.TitleBar);
try {
const { Component, props, path } = await init();
const { Component, props, path, persistence } = await init();
const persistence =
(path !== "/sessionexpired" && path !== "/account/recovery") ||
Config.get("sessionExpired", false)
? "db"
: "memory";
await useKeyStore.getState().init({ persistence });
root.render(

View File

@@ -123,6 +123,7 @@ function useAuthenticateUser({
const user = await db.user.fetchUser();
setUser(user);
} catch (e) {
console.error(e);
showToast("error", strings.biometricsAuthFailed());
openURL("/");
} finally {