diff --git a/src/hooks/usePath.ts b/src/hooks/usePath.ts index 2f23ca98a4..fe93febff9 100644 --- a/src/hooks/usePath.ts +++ b/src/hooks/usePath.ts @@ -7,6 +7,7 @@ import { getPagination, objStore, recoverScroll, + me, } from "~/store" import { fsGet, @@ -19,6 +20,8 @@ import { import { useFetch } from "./useFetch" import { useRouter } from "./useRouter" +let first_fetch = true + let cancelList: Canceler export function addOrUpdateQuery( key: string, @@ -75,7 +78,7 @@ export const resetGlobalPage = () => { console.log("resetGlobalPage", globalPage) } export const usePath = () => { - const { pathname } = useRouter() + const { pathname, to } = useRouter() const [, getObj] = useFetch((path: string) => fsGet(path, password())) const pagination = getPagination() if (pagination.type === "pagination" && getQueryVariable("page")) { @@ -204,6 +207,11 @@ export const usePath = () => { notify.error(msg) } } else { + if (first_fetch && msg.endsWith("object not found")) { + first_fetch = false + to(pathname().replace(me().base_path, "")) + return + } ObjStore.setErr(msg) } }