refactor: use suspense in AppDefender (#1020)

This commit is contained in:
Himself65
2023-02-15 02:51:44 -06:00
committed by GitHub
parent eb1d4fe1f6
commit 34a3a99d62
6 changed files with 44 additions and 47 deletions

View File

@@ -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

View File

@@ -18,7 +18,6 @@ export type AppStateValue = {
workspaceList: WorkspaceUnit[];
currentWorkspace: WorkspaceUnit | null;
pageList: PageMeta[];
synced: boolean;
blobDataSynced?: boolean;
};