diff --git a/packages/frontend/core/src/components/page-list/page-group.tsx b/packages/frontend/core/src/components/page-list/page-group.tsx
index 195be4700..9f2a7984e 100644
--- a/packages/frontend/core/src/components/page-list/page-group.tsx
+++ b/packages/frontend/core/src/components/page-list/page-group.tsx
@@ -9,7 +9,7 @@ import { useLiveData, useService } from '@toeverything/infra';
import clsx from 'clsx';
import { selectAtom } from 'jotai/utils';
import type { MouseEventHandler } from 'react';
-import { useCallback, useMemo, useState } from 'react';
+import { memo, useCallback, useMemo, useState } from 'react';
import { CollectionListItem } from './collections/collection-list-item';
import { PageListItem } from './docs/page-list-item';
@@ -240,7 +240,7 @@ export const PageListItemRenderer = (item: ListItem) => {
);
};
-export const CollectionListItemRenderer = (item: ListItem) => {
+export const CollectionListItemRenderer = memo((item: ListItem) => {
const props = useAtomValue(listsPropsAtom);
const { selectionActive } = useAtomValue(selectionStateAtom);
const collection = item as CollectionMeta;
@@ -252,7 +252,9 @@ export const CollectionListItemRenderer = (item: ListItem) => {
})}
/>
);
-};
+});
+
+CollectionListItemRenderer.displayName = 'CollectionListItemRenderer';
export const TagListItemRenderer = (item: ListItem) => {
const props = useAtomValue(listsPropsAtom);
diff --git a/packages/frontend/core/src/components/pure/workspace-mode-filter-tab/index.tsx b/packages/frontend/core/src/components/pure/workspace-mode-filter-tab/index.tsx
index c34b9148f..816c09a2e 100644
--- a/packages/frontend/core/src/components/pure/workspace-mode-filter-tab/index.tsx
+++ b/packages/frontend/core/src/components/pure/workspace-mode-filter-tab/index.tsx
@@ -1,9 +1,9 @@
import { RadioGroup, type RadioItem } from '@affine/component';
import type { AllPageFilterOption } from '@affine/core/components/atoms';
import { allPageFilterSelectAtom } from '@affine/core/components/atoms';
-import { useNavigateHelper } from '@affine/core/components/hooks/use-navigate-helper';
+import { WorkbenchService } from '@affine/core/modules/workbench';
import { useI18n } from '@affine/i18n';
-import { useService, WorkspaceService } from '@toeverything/infra';
+import { useService } from '@toeverything/infra';
import { useAtom } from 'jotai';
import { useCallback, useEffect, useMemo, useState } from 'react';
@@ -14,26 +14,25 @@ export const WorkspaceModeFilterTab = ({
}: {
activeFilter: AllPageFilterOption;
}) => {
- const workspace = useService(WorkspaceService).workspace;
const t = useI18n();
const [value, setValue] = useState(activeFilter);
const [filterMode, setFilterMode] = useAtom(allPageFilterSelectAtom);
- const { jumpToCollections, jumpToTags, jumpToPage } = useNavigateHelper();
+ const workbenchService = useService(WorkbenchService);
const handleValueChange = useCallback(
(value: AllPageFilterOption) => {
switch (value) {
case 'collections':
- jumpToCollections(workspace.id);
+ workbenchService.workbench.openCollections();
break;
case 'tags':
- jumpToTags(workspace.id);
+ workbenchService.workbench.openTags();
break;
case 'docs':
- jumpToPage(workspace.id, 'all');
+ workbenchService.workbench.openAll();
break;
}
},
- [jumpToCollections, jumpToPage, jumpToTags, workspace]
+ [workbenchService.workbench]
);
useEffect(() => {
diff --git a/packages/frontend/core/src/components/root-app-sidebar/index.tsx b/packages/frontend/core/src/components/root-app-sidebar/index.tsx
index 0b3b1c94d..6f003c918 100644
--- a/packages/frontend/core/src/components/root-app-sidebar/index.tsx
+++ b/packages/frontend/core/src/components/root-app-sidebar/index.tsx
@@ -1,4 +1,3 @@
-import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks';
import {
AddPageButton,
AppDownloadButton,
@@ -23,7 +22,6 @@ import {
} from '@affine/core/modules/explorer';
import { ExplorerTags } from '@affine/core/modules/explorer/views/sections/tags';
import { CMDKQuickSearchService } from '@affine/core/modules/quicksearch/services/cmdk';
-import { isNewTabTrigger } from '@affine/core/utils';
import { useI18n } from '@affine/i18n';
import { track } from '@affine/track';
import type { Doc } from '@blocksuite/affine/store';
@@ -35,17 +33,11 @@ import {
SettingsIcon,
} from '@blocksuite/icons/rc';
import type { Workspace } from '@toeverything/infra';
-import {
- useLiveData,
- useService,
- useServices,
- WorkspaceService,
-} from '@toeverything/infra';
-import type { MouseEvent, ReactElement } from 'react';
-import { useCallback } from 'react';
+import { useLiveData, useService, useServices } from '@toeverything/infra';
+import type { ReactElement } from 'react';
+import { memo, useCallback } from 'react';
import { WorkbenchService } from '../../modules/workbench';
-import { usePageHelper } from '../blocksuite/block-suite-page-list/utils';
import { WorkspaceNavigator } from '../workspace-selector';
import {
quickSearch,
@@ -72,42 +64,43 @@ export type RootAppSidebarProps = {
};
};
+const AllDocsButton = () => {
+ const t = useI18n();
+ const { workbenchService } = useServices({
+ WorkbenchService,
+ });
+ const workbench = workbenchService.workbench;
+ const allPageActive = useLiveData(
+ workbench.location$.selector(location => location.pathname === '/all')
+ );
+
+ return (
+ } active={allPageActive} to={'/all'}>
+
+ {t['com.affine.workspaceSubPath.all']()}
+
+
+ );
+};
+
/**
* This is for the whole affine app sidebar.
* This component wraps the app sidebar in `@affine/component` with logic and data.
*
*/
-export const RootAppSidebar = (): ReactElement => {
- const { workbenchService, workspaceService, cMDKQuickSearchService } =
- useServices({
- WorkspaceService,
- WorkbenchService,
- CMDKQuickSearchService,
- });
- const currentWorkspace = workspaceService.workspace;
+export const RootAppSidebar = memo((): ReactElement => {
+ const { workbenchService, cMDKQuickSearchService } = useServices({
+ WorkbenchService,
+ CMDKQuickSearchService,
+ });
const t = useI18n();
const globalDialogService = useService(GlobalDialogService);
const workspaceDialogService = useService(WorkspaceDialogService);
const workbench = workbenchService.workbench;
- const currentPath = useLiveData(
- workbench.location$.map(location => location.pathname)
- );
const onOpenQuickSearchModal = useCallback(() => {
cMDKQuickSearchService.toggle();
}, [cMDKQuickSearchService]);
- const allPageActive = currentPath === '/all';
-
- const pageHelper = usePageHelper(currentWorkspace.docCollection);
-
- const onClickNewPage = useAsyncCallback(
- async (e?: MouseEvent) => {
- pageHelper.createPage(undefined, isNewTabTrigger(e) ? 'new-tab' : true);
- track.$.navigationPanel.$.createDoc();
- },
- [pageHelper]
- );
-
const onOpenSettingModal = useCallback(() => {
globalDialogService.open('setting', {
activeTab: 'appearance',
@@ -169,13 +162,9 @@ export const RootAppSidebar = (): ReactElement => {
data-event-props="$.navigationPanel.$.quickSearch"
onClick={onOpenQuickSearchModal}
/>
-
+
- } active={allPageActive} to={'/all'}>
-
- {t['com.affine.workspaceSubPath.all']()}
-
-
+