chore: add track event to toggle sidebar switch (#8582)

close AF-1530
This commit is contained in:
JimmFly
2024-10-24 03:36:10 +00:00
parent 8cbb7195fc
commit 021587ffab
3 changed files with 8 additions and 1 deletions

View File

@@ -27,7 +27,9 @@ export function registerAffineLayoutCommands({
binding: '$mod+/',
},
run() {
track.$.navigationPanel.$.toggle();
track.$.navigationPanel.$.toggle({
type: appSidebarService.sidebar.open$.value ? 'collapse' : 'expand',
});
appSidebarService.sidebar.toggleSidebar();
},
})

View File

@@ -1,5 +1,6 @@
import { IconButton } from '@affine/component';
import { useI18n } from '@affine/i18n';
import { track } from '@affine/track';
import { SidebarIcon } from '@blocksuite/icons/rc';
import { useLiveData, useService } from '@toeverything/infra';
import { useCallback, useRef } from 'react';
@@ -27,6 +28,9 @@ export const SidebarSwitch = ({
}, [appSidebarService, open, preventHovering]);
const handleClickSwitch = useCallback(() => {
track.$.navigationPanel.$.toggle({
type: open ? 'collapse' : 'expand',
});
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
}