Files
twenty/front/src/modules/activities/hooks/useOpenTimelineRightDrawer.ts
Charles Bochet 35ea6b5a2f Remove activityType and Id (#1179)
* Remove activityType and Id

* Fix tests

* Fix tests
2023-08-11 17:31:54 -07:00

27 lines
1.1 KiB
TypeScript

import { useRecoilState } from 'recoil';
import { useRightDrawer } from '@/ui/right-drawer/hooks/useRightDrawer';
import { RightDrawerHotkeyScope } from '@/ui/right-drawer/types/RightDrawerHotkeyScope';
import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages';
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
import { activityTargetableEntityArrayState } from '../states/activityTargetableEntityArrayState';
import { ActivityTargetableEntity } from '../types/ActivityTargetableEntity';
// TODO: refactor with recoil callback to avoid rerender
export function useOpenTimelineRightDrawer() {
const { openRightDrawer } = useRightDrawer();
const [, setActivityTargetableEntityArray] = useRecoilState(
activityTargetableEntityArrayState,
);
const setHotkeyScope = useSetHotkeyScope();
return function openTimelineRightDrawer(
activityTargetableEntityArray: ActivityTargetableEntity[],
) {
setHotkeyScope(RightDrawerHotkeyScope.RightDrawer, { goto: false });
setActivityTargetableEntityArray(activityTargetableEntityArray);
openRightDrawer(RightDrawerPages.Timeline);
};
}