Skip to content

Commit

Permalink
Refresh inbox messages onArchive.
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonfancher committed Oct 10, 2024
1 parent fdb7a19 commit 18951cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions services/user/Chainmail/ui/src/components/mail-display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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,
Expand Down Expand Up @@ -85,6 +87,7 @@ const ActionBar = ({
mailbox: Mailbox;
message: Message;
}) => {
const queryClient = useQueryClient();
const { setSelectedMessageId: setInboxMessageId } = useIncomingMessages();
const {
selectedMessage: selectedDraftMessage,
Expand All @@ -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) => {
Expand Down
2 changes: 2 additions & 0 deletions services/user/Chainmail/ui/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ export function debounce<T extends (...args: any[]) => any>(
};
return <T>(<any>callable);
}

export const wait = (ms: number) => new Promise((res) => setTimeout(res, ms));

0 comments on commit 18951cf

Please sign in to comment.