mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 06:16:59 +08:00
refactor(core): refactor left sidebar to use di (#8385)
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
import type { useI18n } from '@affine/i18n';
|
||||
import { track } from '@affine/track';
|
||||
import { SidebarIcon } from '@blocksuite/icons/rc';
|
||||
import type { createStore } from 'jotai';
|
||||
|
||||
import { appSidebarOpenAtom } from '../components/app-sidebar';
|
||||
import type { AppSidebarService } from '../modules/app-sidebar';
|
||||
import { registerAffineCommand } from './registry';
|
||||
|
||||
export function registerAffineLayoutCommands({
|
||||
t,
|
||||
store,
|
||||
appSidebarService,
|
||||
}: {
|
||||
t: ReturnType<typeof useI18n>;
|
||||
store: ReturnType<typeof createStore>;
|
||||
appSidebarService: AppSidebarService;
|
||||
}) {
|
||||
const unsubs: Array<() => void> = [];
|
||||
unsubs.push(
|
||||
@@ -20,7 +19,7 @@ export function registerAffineLayoutCommands({
|
||||
category: 'affine:layout',
|
||||
icon: <SidebarIcon />,
|
||||
label: () =>
|
||||
store.get(appSidebarOpenAtom)
|
||||
appSidebarService.sidebar.open$.value
|
||||
? t['com.affine.cmdk.affine.left-sidebar.collapse']()
|
||||
: t['com.affine.cmdk.affine.left-sidebar.expand'](),
|
||||
|
||||
@@ -29,8 +28,7 @@ export function registerAffineLayoutCommands({
|
||||
},
|
||||
run() {
|
||||
track.$.navigationPanel.$.toggle();
|
||||
|
||||
store.set(appSidebarOpenAtom, v => !v);
|
||||
appSidebarService.sidebar.toggleSidebar();
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user