From 4560819f76a34946d05119aad469b1136cfef746 Mon Sep 17 00:00:00 2001 From: EYHN Date: Thu, 22 Feb 2024 14:11:11 +0700 Subject: [PATCH] fix(core): fix 404 after signout (hotfix) (#5865) --- packages/frontend/core/src/pages/index.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/frontend/core/src/pages/index.tsx b/packages/frontend/core/src/pages/index.tsx index 03ea0d3d5c..995216d02f 100644 --- a/packages/frontend/core/src/pages/index.tsx +++ b/packages/frontend/core/src/pages/index.tsx @@ -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);