fix(core): fix 404 after signout (hotfix) (#5865)

This commit is contained in:
EYHN
2024-02-22 14:11:11 +07:00
committed by GitHub
parent 193c197a54
commit 4560819f76
+8 -3
View File
@@ -1,6 +1,9 @@
import { Menu } from '@affine/component/ui/menu';
import { WorkspaceFallback } from '@affine/component/workspace';
import { workspaceListAtom } from '@affine/core/modules/workspace';
import {
workspaceListAtom,
workspaceListLoadingStatusAtom,
} from '@affine/core/modules/workspace';
import { WorkspaceSubPath } from '@affine/core/shared';
import { useAtomValue } from 'jotai';
import { lazy, useEffect, useLayoutEffect, useState } from 'react';
@@ -30,10 +33,12 @@ export const Component = () => {
const [creating, setCreating] = useState(false);
const list = useAtomValue(workspaceListAtom);
const listLoading = useAtomValue(workspaceListLoadingStatusAtom);
const { openPage } = useNavigateHelper();
useLayoutEffect(() => {
if (list.length === 0) {
if (list.length === 0 && !listLoading) {
return;
}
@@ -42,7 +47,7 @@ export const Component = () => {
const openWorkspace = list.find(w => w.id === lastId) ?? list[0];
openPage(openWorkspace.id, WorkspaceSubPath.ALL);
setNavigating(true);
}, [list, openPage]);
}, [list, listLoading, openPage]);
useEffect(() => {
setCreating(true);