fix #52: correct the StackedRouter on 'replace'
All checks were successful
/ depoly (push) Successful in 1m26s

This commit is contained in:
thislight 2024-12-21 20:19:02 +08:00
parent ee67993796
commit ee31c38f32
No known key found for this signature in database
GPG key ID: FCFE5192241CCD4E
5 changed files with 61 additions and 25 deletions

View file

@ -4,6 +4,7 @@ import {
createMemo,
createRenderEffect,
createResource,
untrack,
useContext,
} from "solid-js";
import { Account } from "../accounts/stores";
@ -57,15 +58,15 @@ export const Provider = Context.Provider;
export function useSessions() {
const sessions = useSessionsRaw();
const {push} = useNavigator();
const { push } = useNavigator();
const location = useLocation();
createRenderEffect(() => {
if (sessions().length > 0) return;
push(
"/accounts/sign-in?back=" + encodeURIComponent(location.pathname),
{ replace: "all" },
);
if (untrack(() => sessions().length) > 0) return;
push("/accounts/sign-in?back=" + encodeURIComponent(location.pathname), {
replace: true,
});
});
return sessions;