mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 18:26:05 +08:00
refactor: use suspense in AppDefender (#1020)
This commit is contained in:
@@ -45,21 +45,14 @@ export const AppStateProvider = ({
|
||||
|
||||
const onceRef = useRef(true);
|
||||
const dataCenter = useGlobalState(store => store.dataCenter);
|
||||
useEffect(() => {
|
||||
if (dataCenter !== null) {
|
||||
if (onceRef.current) {
|
||||
setAppState({
|
||||
workspaceList: dataCenter.workspaces,
|
||||
currentWorkspace: null,
|
||||
pageList: [],
|
||||
synced: true,
|
||||
});
|
||||
onceRef.current = false;
|
||||
} else {
|
||||
console.warn('dataCenter Effect called twice. Please fix this ASAP');
|
||||
}
|
||||
}
|
||||
}, [dataCenter]);
|
||||
if (onceRef.current && dataCenter) {
|
||||
setAppState({
|
||||
workspaceList: dataCenter.workspaces,
|
||||
currentWorkspace: null,
|
||||
pageList: [],
|
||||
});
|
||||
onceRef.current = false;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
// FIXME: onWorkspacesChange should have dispose function
|
||||
|
||||
@@ -18,7 +18,6 @@ export type AppStateValue = {
|
||||
workspaceList: WorkspaceUnit[];
|
||||
currentWorkspace: WorkspaceUnit | null;
|
||||
pageList: PageMeta[];
|
||||
synced: boolean;
|
||||
blobDataSynced?: boolean;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user