diff --git a/services/user/Chainmail/ui/src/components/mail-display.tsx b/services/user/Chainmail/ui/src/components/mail-display.tsx index f6812aa04..5fec63bf3 100644 --- a/services/user/Chainmail/ui/src/components/mail-display.tsx +++ b/services/user/Chainmail/ui/src/components/mail-display.tsx @@ -7,6 +7,7 @@ import { format } from "date-fns"; import { Archive, ArchiveRestore, Pin, Trash2 } from "lucide-react"; import { replaceAll } from "@milkdown/utils"; import { toast } from "sonner"; +import { useQueryClient } from "@tanstack/react-query"; import { Avatar, AvatarFallback, AvatarImage } from "@shadcn/avatar"; import { Button } from "@shadcn/button"; @@ -24,6 +25,7 @@ import { } from "@components"; import { Message, useDraftMessages, useIncomingMessages } from "@hooks"; import { getSupervisor } from "@lib/supervisor"; +import { wait } from "@lib/utils"; export function MailDisplay({ message, @@ -85,6 +87,7 @@ const ActionBar = ({ mailbox: Mailbox; message: Message; }) => { + const queryClient = useQueryClient(); const { setSelectedMessageId: setInboxMessageId } = useIncomingMessages(); const { selectedMessage: selectedDraftMessage, @@ -111,6 +114,10 @@ const ActionBar = ({ }); setInboxMessageId(""); toast.success("Your message has been archived"); + await wait(3000); + queryClient.invalidateQueries({ + queryKey: ["incoming"], + }); }; const onUnArchive = (itemId: string) => { diff --git a/services/user/Chainmail/ui/src/lib/utils.ts b/services/user/Chainmail/ui/src/lib/utils.ts index c8b5b8dab..3c73df14b 100644 --- a/services/user/Chainmail/ui/src/lib/utils.ts +++ b/services/user/Chainmail/ui/src/lib/utils.ts @@ -25,3 +25,5 @@ export function debounce any>( }; return (callable); } + +export const wait = (ms: number) => new Promise((res) => setTimeout(res, ms));