mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-22 19:53:48 +08:00
fix(core): duplicate registration in edgeless (#4864)
This commit is contained in:
@@ -26,59 +26,87 @@ export function useRegisterWorkspaceCommands() {
|
|||||||
const pageHelper = usePageHelper(currentWorkspace.blockSuiteWorkspace);
|
const pageHelper = usePageHelper(currentWorkspace.blockSuiteWorkspace);
|
||||||
const navigationHelper = useNavigateHelper();
|
const navigationHelper = useNavigateHelper();
|
||||||
const [pageListMode, setPageListMode] = useAtom(allPageModeSelectAtom);
|
const [pageListMode, setPageListMode] = useAtom(allPageModeSelectAtom);
|
||||||
|
|
||||||
|
// register AffineUpdatesCommands
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const unsubs: Array<() => void> = [];
|
const unsub = registerAffineUpdatesCommands({
|
||||||
unsubs.push(
|
store,
|
||||||
registerAffineUpdatesCommands({
|
t,
|
||||||
store,
|
});
|
||||||
t,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
unsubs.push(
|
|
||||||
registerAffineNavigationCommands({
|
|
||||||
store,
|
|
||||||
t,
|
|
||||||
workspace: currentWorkspace.blockSuiteWorkspace,
|
|
||||||
navigationHelper,
|
|
||||||
pageListMode,
|
|
||||||
setPageListMode,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
unsubs.push(
|
|
||||||
registerAffineSettingsCommands({
|
|
||||||
store,
|
|
||||||
t,
|
|
||||||
theme,
|
|
||||||
languageHelper,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
unsubs.push(registerAffineLayoutCommands({ t, store }));
|
|
||||||
unsubs.push(
|
|
||||||
registerAffineCreationCommands({
|
|
||||||
store,
|
|
||||||
pageHelper: pageHelper,
|
|
||||||
t,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
unsubs.push(
|
|
||||||
registerAffineHelpCommands({
|
|
||||||
store,
|
|
||||||
t,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
unsubs.forEach(unsub => unsub());
|
unsub();
|
||||||
|
};
|
||||||
|
}, [store, t]);
|
||||||
|
|
||||||
|
// register AffineNavigationCommands
|
||||||
|
useEffect(() => {
|
||||||
|
const unsub = registerAffineNavigationCommands({
|
||||||
|
store,
|
||||||
|
t,
|
||||||
|
workspace: currentWorkspace.blockSuiteWorkspace,
|
||||||
|
navigationHelper,
|
||||||
|
pageListMode,
|
||||||
|
setPageListMode,
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
unsub();
|
||||||
};
|
};
|
||||||
}, [
|
}, [
|
||||||
store,
|
store,
|
||||||
pageHelper,
|
|
||||||
t,
|
t,
|
||||||
theme,
|
|
||||||
currentWorkspace.blockSuiteWorkspace,
|
currentWorkspace.blockSuiteWorkspace,
|
||||||
navigationHelper,
|
navigationHelper,
|
||||||
pageListMode,
|
pageListMode,
|
||||||
setPageListMode,
|
setPageListMode,
|
||||||
languageHelper,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// register AffineSettingsCommands
|
||||||
|
useEffect(() => {
|
||||||
|
const unsub = registerAffineSettingsCommands({
|
||||||
|
store,
|
||||||
|
t,
|
||||||
|
theme,
|
||||||
|
languageHelper,
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
unsub();
|
||||||
|
};
|
||||||
|
}, [store, t, theme, languageHelper]);
|
||||||
|
|
||||||
|
// register AffineLayoutCommands
|
||||||
|
useEffect(() => {
|
||||||
|
const unsub = registerAffineLayoutCommands({ t, store });
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
unsub();
|
||||||
|
};
|
||||||
|
}, [store, t]);
|
||||||
|
|
||||||
|
// register AffineCreationCommands
|
||||||
|
useEffect(() => {
|
||||||
|
const unsub = registerAffineCreationCommands({
|
||||||
|
store,
|
||||||
|
pageHelper: pageHelper,
|
||||||
|
t,
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
unsub();
|
||||||
|
};
|
||||||
|
}, [store, pageHelper, t]);
|
||||||
|
|
||||||
|
// register AffineHelpCommands
|
||||||
|
useEffect(() => {
|
||||||
|
const unsub = registerAffineHelpCommands({
|
||||||
|
store,
|
||||||
|
t,
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
unsub();
|
||||||
|
};
|
||||||
|
}, [store, t]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const DetailPageImpl = (): ReactElement => {
|
|||||||
assertExists(currentWorkspace);
|
assertExists(currentWorkspace);
|
||||||
assertExists(currentPageId);
|
assertExists(currentPageId);
|
||||||
const blockSuiteWorkspace = currentWorkspace.blockSuiteWorkspace;
|
const blockSuiteWorkspace = currentWorkspace.blockSuiteWorkspace;
|
||||||
const collectionManager = useCollectionManager(collectionsCRUDAtom);
|
const { setTemporaryFilter } = useCollectionManager(collectionsCRUDAtom);
|
||||||
const mode = useAtomValue(currentModeAtom);
|
const mode = useAtomValue(currentModeAtom);
|
||||||
const setPageMode = useSetAtom(setPageModeAtom);
|
const setPageMode = useSetAtom(setPageModeAtom);
|
||||||
useRegisterBlocksuiteEditorCommands(blockSuiteWorkspace, currentPageId, mode);
|
useRegisterBlocksuiteEditorCommands(blockSuiteWorkspace, currentPageId, mode);
|
||||||
@@ -67,7 +67,7 @@ const DetailPageImpl = (): ReactElement => {
|
|||||||
});
|
});
|
||||||
const disposeTagClick = editor.slots.tagClicked.on(async ({ tagId }) => {
|
const disposeTagClick = editor.slots.tagClicked.on(async ({ tagId }) => {
|
||||||
jumpToSubPath(currentWorkspace.id, WorkspaceSubPath.ALL);
|
jumpToSubPath(currentWorkspace.id, WorkspaceSubPath.ALL);
|
||||||
collectionManager.setTemporaryFilter([createTagFilter(tagId)]);
|
setTemporaryFilter([createTagFilter(tagId)]);
|
||||||
});
|
});
|
||||||
return () => {
|
return () => {
|
||||||
dispose.dispose();
|
dispose.dispose();
|
||||||
@@ -76,13 +76,13 @@ const DetailPageImpl = (): ReactElement => {
|
|||||||
},
|
},
|
||||||
[
|
[
|
||||||
blockSuiteWorkspace.id,
|
blockSuiteWorkspace.id,
|
||||||
collectionManager,
|
|
||||||
currentPageId,
|
currentPageId,
|
||||||
currentWorkspace.id,
|
currentWorkspace.id,
|
||||||
jumpToSubPath,
|
jumpToSubPath,
|
||||||
mode,
|
mode,
|
||||||
openPage,
|
openPage,
|
||||||
setPageMode,
|
setPageMode,
|
||||||
|
setTemporaryFilter,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user