mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-13 12:54:59 +08:00
fix(core): fix 404 after signout (#5866)
CherryPick https://github.com/toeverything/AFFiNE/pull/5865
This commit is contained in:
@@ -32,19 +32,22 @@ export const Component = () => {
|
|||||||
const [creating, setCreating] = useState(false);
|
const [creating, setCreating] = useState(false);
|
||||||
|
|
||||||
const list = useLiveData(useService(WorkspaceListService).workspaceList);
|
const list = useLiveData(useService(WorkspaceListService).workspaceList);
|
||||||
|
const workspaceStatus = useLiveData(useService(WorkspaceListService).status);
|
||||||
|
|
||||||
const { openPage } = useNavigateHelper();
|
const { openPage } = useNavigateHelper();
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (list.length === 0) {
|
if (list.length === 0 || workspaceStatus.loading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open last workspace
|
// open last workspace
|
||||||
const lastId = localStorage.getItem('last_workspace_id');
|
const lastId = localStorage.getItem('last_workspace_id');
|
||||||
|
|
||||||
const openWorkspace = list.find(w => w.id === lastId) ?? list[0];
|
const openWorkspace = list.find(w => w.id === lastId) ?? list[0];
|
||||||
openPage(openWorkspace.id, WorkspaceSubPath.ALL);
|
openPage(openWorkspace.id, WorkspaceSubPath.ALL);
|
||||||
setNavigating(true);
|
setNavigating(true);
|
||||||
}, [list, openPage]);
|
}, [list, workspaceStatus, openPage]);
|
||||||
|
|
||||||
const workspaceManager = useService(WorkspaceManager);
|
const workspaceManager = useService(WorkspaceManager);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user