* Fix naming * Fixed cache.evict bug for relation target deletion * Fixed cascade delete activity targets * Working version * Fix * fix * WIP * Fixed optimistic effect target inline cell * Removed openCreateActivityDrawer v1 * Ok for timeline * Removed console.log * Fix update record optimistic effect * Refactored activity queries into useActivities for everything * Fixed bugs * Cleaned * Fix lint --------- Co-authored-by: Charles Bochet <charles@twenty.com>
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { useRecoilState } from 'recoil';
|
|
|
|
import { activityInDrawerState } from '@/activities/states/activityInDrawerState';
|
|
import { Activity } from '@/activities/types/Activity';
|
|
import { useRightDrawer } from '@/ui/layout/right-drawer/hooks/useRightDrawer';
|
|
import { RightDrawerHotkeyScope } from '@/ui/layout/right-drawer/types/RightDrawerHotkeyScope';
|
|
import { RightDrawerPages } from '@/ui/layout/right-drawer/types/RightDrawerPages';
|
|
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
|
|
|
|
import { viewableActivityIdState } from '../states/viewableActivityIdState';
|
|
|
|
export const useOpenActivityRightDrawer = () => {
|
|
const { openRightDrawer, isRightDrawerOpen, rightDrawerPage } =
|
|
useRightDrawer();
|
|
const [viewableActivityId, setViewableActivityId] = useRecoilState(
|
|
viewableActivityIdState,
|
|
);
|
|
const [, setActivityInDrawer] = useRecoilState(activityInDrawerState);
|
|
const setHotkeyScope = useSetHotkeyScope();
|
|
|
|
return (activity: Activity) => {
|
|
if (
|
|
isRightDrawerOpen &&
|
|
rightDrawerPage === RightDrawerPages.EditActivity &&
|
|
viewableActivityId === activity.id
|
|
) {
|
|
return;
|
|
}
|
|
|
|
setHotkeyScope(RightDrawerHotkeyScope.RightDrawer, { goto: false });
|
|
setViewableActivityId(activity.id);
|
|
setActivityInDrawer(activity);
|
|
openRightDrawer(RightDrawerPages.EditActivity);
|
|
};
|
|
};
|