From 86c48e4667d3cdbd2dfbde46b5abbd6fa5e0e039 Mon Sep 17 00:00:00 2001 From: Eliezer Steinbock <3090527+elie222@users.noreply.github.com> Date: Fri, 10 Jan 2025 13:01:20 +0200 Subject: [PATCH] Fix mail row disappearing and auto closing when clicking a row --- apps/web/app/(app)/mail/page.tsx | 6 +++--- apps/web/components/CommandK.tsx | 2 +- apps/web/components/email-list/EmailList.tsx | 12 ++++++------ apps/web/store/email.ts | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/web/app/(app)/mail/page.tsx b/apps/web/app/(app)/mail/page.tsx index d74707ad0..507240c62 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 80581ec07..d522389c4 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 0054f4ad6..d11de0595 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 c860de065..a73025ba8 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);