first prototype of StackedRouter

This commit is contained in:
thislight 2024-11-16 20:04:55 +08:00
parent 607fa64c05
commit 0710aaf4f3
No known key found for this signature in database
GPG key ID: FCFE5192241CCD4E
21 changed files with 442 additions and 109 deletions

View file

@ -8,7 +8,8 @@ import {
} from "solid-js";
import { Account } from "../accounts/stores";
import { createRestAPIClient, mastodon } from "masto";
import { useLocation, useNavigate } from "@solidjs/router";
import { useLocation } from "@solidjs/router";
import { useNavigator } from "../platform/StackedRouter";
const restfulCache: Record<string, mastodon.rest.Client> = {};
@ -56,12 +57,12 @@ export const Provider = Context.Provider;
export function useSessions() {
const sessions = useSessionsRaw();
const navigate = useNavigate();
const {push} = useNavigator();
const location = useLocation();
createRenderEffect(() => {
if (sessions().length > 0) return;
navigate(
push(
"/accounts/sign-in?back=" + encodeURIComponent(location.pathname),
{ replace: true },
);