Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);