Skip to content

Commit

Permalink
Merge pull request #303 from elie222/fix/mail-email-disappear
Browse files Browse the repository at this point in the history
Fix mail row disappearing and auto closing when clicking a row
  • Loading branch information
elie222 authored Jan 10, 2025
2 parents 960a224 + 86c48e4 commit 0af6afe
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions apps/web/app/(app)/mail/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
}));
},
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/CommandK.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 6 additions & 6 deletions apps/web/components/email-list/EmailList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -278,7 +278,7 @@ export function EmailList({
threadIds,
undefined,
(threadId) => {
refetch([threadId]);
refetch({ removedThreadIds: [threadId] });
resolve();
},
reject,
Expand Down Expand Up @@ -361,7 +361,7 @@ export function EmailList({
threadIds,
undefined,
() => {
refetch(threadIds);
refetch({ removedThreadIds: threadIds });
resolve();
},
reject,
Expand All @@ -387,7 +387,7 @@ export function EmailList({
deleteEmails(
threadIds,
() => {
refetch(threadIds);
refetch({ removedThreadIds: threadIds });
resolve();
},
reject,
Expand Down Expand Up @@ -490,7 +490,7 @@ export function EmailList({

if (!alreadyOpen) scrollToId(thread.id);

markReadThreads([thread.id], () => refetch([thread.id]));
markReadThreads([thread.id], () => refetch());
};

return (
Expand Down
2 changes: 1 addition & 1 deletion apps/web/store/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { atom } from "jotai";

export const selectedEmailAtom = atom<string | undefined>(undefined);
export const refetchEmailListAtom = atom<
{ refetch: (removedThreadIds?: string[]) => void } | undefined
{ refetch: (options?: { removedThreadIds?: string[] }) => void } | undefined
>(undefined);

1 comment on commit 0af6afe

@vercel
Copy link

@vercel vercel bot commented on 0af6afe Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.