mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00: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 navigationHelper = useNavigateHelper();
|
||||
const [pageListMode, setPageListMode] = useAtom(allPageModeSelectAtom);
|
||||
|
||||
// register AffineUpdatesCommands
|
||||
useEffect(() => {
|
||||
const unsubs: Array<() => void> = [];
|
||||
unsubs.push(
|
||||
registerAffineUpdatesCommands({
|
||||
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,
|
||||
})
|
||||
);
|
||||
const unsub = registerAffineUpdatesCommands({
|
||||
store,
|
||||
t,
|
||||
});
|
||||
|
||||
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,
|
||||
pageHelper,
|
||||
t,
|
||||
theme,
|
||||
currentWorkspace.blockSuiteWorkspace,
|
||||
navigationHelper,
|
||||
pageListMode,
|
||||
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(currentPageId);
|
||||
const blockSuiteWorkspace = currentWorkspace.blockSuiteWorkspace;
|
||||
const collectionManager = useCollectionManager(collectionsCRUDAtom);
|
||||
const { setTemporaryFilter } = useCollectionManager(collectionsCRUDAtom);
|
||||
const mode = useAtomValue(currentModeAtom);
|
||||
const setPageMode = useSetAtom(setPageModeAtom);
|
||||
useRegisterBlocksuiteEditorCommands(blockSuiteWorkspace, currentPageId, mode);
|
||||
@@ -67,7 +67,7 @@ const DetailPageImpl = (): ReactElement => {
|
||||
});
|
||||
const disposeTagClick = editor.slots.tagClicked.on(async ({ tagId }) => {
|
||||
jumpToSubPath(currentWorkspace.id, WorkspaceSubPath.ALL);
|
||||
collectionManager.setTemporaryFilter([createTagFilter(tagId)]);
|
||||
setTemporaryFilter([createTagFilter(tagId)]);
|
||||
});
|
||||
return () => {
|
||||
dispose.dispose();
|
||||
@@ -76,13 +76,13 @@ const DetailPageImpl = (): ReactElement => {
|
||||
},
|
||||
[
|
||||
blockSuiteWorkspace.id,
|
||||
collectionManager,
|
||||
currentPageId,
|
||||
currentWorkspace.id,
|
||||
jumpToSubPath,
|
||||
mode,
|
||||
openPage,
|
||||
setPageMode,
|
||||
setTemporaryFilter,
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user