Fetch viewable thread from apollo cache (#3783)

Co-authored-by: Thomas Trompette <thomast@twenty.com>
This commit is contained in:
Thomas Trompette
2024-02-02 14:41:00 +01:00
committed by GitHub
parent 096f2c456c
commit 8816b7fb31
6 changed files with 80 additions and 52 deletions

View File

@ -1,18 +1,19 @@
import { useRecoilState } from 'recoil';
import { useOpenEmailThreadRightDrawer } from '@/activities/emails/right-drawer/hooks/useOpenEmailThreadRightDrawer';
import { viewableEmailThreadState } from '@/activities/emails/state/viewableEmailThreadState';
import { TimelineThread } from '~/generated/graphql';
import { viewableEmailThreadIdState } from '@/activities/emails/state/viewableEmailThreadIdState';
export const useEmailThread = () => {
const [, setViewableEmailThread] = useRecoilState(viewableEmailThreadState);
const [, setViewableEmailThreadId] = useRecoilState(
viewableEmailThreadIdState,
);
const openEmailThredRightDrawer = useOpenEmailThreadRightDrawer();
const openEmailThread = (thread: TimelineThread) => {
const openEmailThread = (threadId: string) => {
openEmailThredRightDrawer();
setViewableEmailThread(thread);
setViewableEmailThreadId(threadId);
};
return {