Skip to content

Commit

Permalink
chore: add track event to toggle sidebar switch (toeverything#8582)
Browse files Browse the repository at this point in the history
close AF-1530
  • Loading branch information
JimmFly committed Oct 24, 2024
1 parent 8cbb719 commit 021587f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/frontend/core/src/commands/affine-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
})
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/track/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ export type EventArgs = {
action: TabActionType;
};
toggleFavorite: OrganizeItemArgs & { on: boolean };
toggle: { type: 'collapse' | 'expand' };
createDoc: { mode?: 'edgeless' | 'page' };
switchPageMode: { mode: 'edgeless' | 'page' };
createShareLink: { mode: 'edgeless' | 'page' };
Expand Down

0 comments on commit 021587f

Please sign in to comment.