diff --git a/apps/web/app/(app)/mail/page.tsx b/apps/web/app/(app)/mail/page.tsx index d74707ad0b..507240c62f 100644 --- a/apps/web/app/(app)/mail/page.tsx +++ b/apps/web/app/(app)/mail/page.tsx @@ -49,16 +49,16 @@ export default function Mail({ // store `refetch` in the atom so we can refresh the list upon archive via command k // TODO is this the best way to do this? const refetch = useCallback( - (removedThreadIds?: string[]) => { + (options?: { removedThreadIds?: string[] }) => { mutate( (currentData) => { if (!currentData) return currentData; - if (!removedThreadIds) return currentData; + if (!options?.removedThreadIds) return currentData; return currentData.map((page) => ({ ...page, threads: page.threads.filter( - (t) => !removedThreadIds.includes(t.id), + (t) => !options?.removedThreadIds?.includes(t.id), ), })); }, diff --git a/apps/web/components/CommandK.tsx b/apps/web/components/CommandK.tsx index 80581ec078..d522389c48 100644 --- a/apps/web/components/CommandK.tsx +++ b/apps/web/components/CommandK.tsx @@ -32,7 +32,7 @@ export function CommandK() { if (selectedEmail) { const threadIds = [selectedEmail]; archiveEmails(threadIds, undefined, () => { - return refreshEmailList?.refetch(threadIds); + return refreshEmailList?.refetch({ removedThreadIds: threadIds }); }); setSelectedEmail(undefined); } diff --git a/apps/web/components/email-list/EmailList.tsx b/apps/web/components/email-list/EmailList.tsx index 0054f4ad6e..d11de0595d 100644 --- a/apps/web/components/email-list/EmailList.tsx +++ b/apps/web/components/email-list/EmailList.tsx @@ -47,7 +47,7 @@ export function List({ }: { emails: Thread[]; type?: string; - refetch: (removedThreadIds?: string[]) => void; + refetch: (options?: { removedThreadIds?: string[] }) => void; showLoadMore?: boolean; isLoadingMore?: boolean; handleLoadMore?: () => void; @@ -175,7 +175,7 @@ export function EmailList({ threads?: Thread[]; emptyMessage?: React.ReactNode; hideActionBarWhenEmpty?: boolean; - refetch?: (removedThreadIds?: string[]) => void; + refetch?: (options?: { removedThreadIds?: string[] }) => void; showLoadMore?: boolean; isLoadingMore?: boolean; handleLoadMore?: () => void; @@ -278,7 +278,7 @@ export function EmailList({ threadIds, undefined, (threadId) => { - refetch([threadId]); + refetch({ removedThreadIds: [threadId] }); resolve(); }, reject, @@ -361,7 +361,7 @@ export function EmailList({ threadIds, undefined, () => { - refetch(threadIds); + refetch({ removedThreadIds: threadIds }); resolve(); }, reject, @@ -387,7 +387,7 @@ export function EmailList({ deleteEmails( threadIds, () => { - refetch(threadIds); + refetch({ removedThreadIds: threadIds }); resolve(); }, reject, @@ -490,7 +490,7 @@ export function EmailList({ if (!alreadyOpen) scrollToId(thread.id); - markReadThreads([thread.id], () => refetch([thread.id])); + markReadThreads([thread.id], () => refetch()); }; return ( diff --git a/apps/web/store/email.ts b/apps/web/store/email.ts index c860de0650..a73025ba8e 100644 --- a/apps/web/store/email.ts +++ b/apps/web/store/email.ts @@ -2,5 +2,5 @@ import { atom } from "jotai"; export const selectedEmailAtom = atom(undefined); export const refetchEmailListAtom = atom< - { refetch: (removedThreadIds?: string[]) => void } | undefined + { refetch: (options?: { removedThreadIds?: string[] }) => void } | undefined >(undefined);