feat: add workspace change event handler

This commit is contained in:
QiShaoXuan
2023-01-09 16:51:52 +08:00
parent 28b2943dc6
commit 15f06fe85e

View File

@@ -80,6 +80,17 @@ export const AppStateProvider = ({
};
}, [appState]);
useEffect(() => {
const { dataCenter } = appState;
// FIXME: onWorkspacesChange should have dispose function
dataCenter?.onWorkspacesChange(() => {
setAppState({
...appState,
workspaceList: dataCenter.workspaces,
});
});
}, [appState]);
const loadPage = (pageId: string) => {
const { currentWorkspace, currentPage } = appState;
if (pageId === currentPage?.id) {