mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 05:14:54 +00: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 list = useLiveData(useService(WorkspaceListService).workspaceList);
|
||||
const workspaceStatus = useLiveData(useService(WorkspaceListService).status);
|
||||
|
||||
const { openPage } = useNavigateHelper();
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (list.length === 0) {
|
||||
if (list.length === 0 || workspaceStatus.loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
// open last workspace
|
||||
const lastId = localStorage.getItem('last_workspace_id');
|
||||
|
||||
const openWorkspace = list.find(w => w.id === lastId) ?? list[0];
|
||||
openPage(openWorkspace.id, WorkspaceSubPath.ALL);
|
||||
setNavigating(true);
|
||||
}, [list, openPage]);
|
||||
}, [list, workspaceStatus, openPage]);
|
||||
|
||||
const workspaceManager = useService(WorkspaceManager);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user