From 4951906fcb641b5cdd24256c7cbef66a38d39cd0 Mon Sep 17 00:00:00 2001 From: Zhang Minghan Date: Wed, 25 Oct 2023 17:20:50 +0800 Subject: [PATCH] fix toast --- app/src/components/home/ChatWrapper.tsx | 1 - app/src/components/ui/use-toast.ts | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/components/home/ChatWrapper.tsx b/app/src/components/home/ChatWrapper.tsx index 35b383f6..79bf1c41 100644 --- a/app/src/components/home/ChatWrapper.tsx +++ b/app/src/components/home/ChatWrapper.tsx @@ -29,7 +29,6 @@ import { Dialog, DialogContent, DialogDescription, - DialogFooter, DialogHeader, DialogTitle, DialogTrigger diff --git a/app/src/components/ui/use-toast.ts b/app/src/components/ui/use-toast.ts index 88cfb75f..fe4ba7c2 100644 --- a/app/src/components/ui/use-toast.ts +++ b/app/src/components/ui/use-toast.ts @@ -137,7 +137,7 @@ function dispatch(action: Action) { type Toast = Omit; -function toast({ ...props }: Toast) { +function toast({ ...props }: Toast, timeout?: number) { const id = genId(); const update = (props: ToasterToast) => @@ -147,6 +147,8 @@ function toast({ ...props }: Toast) { }); const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id }); + setTimeout(dismiss, timeout ?? 5000); + dispatch({ type: "ADD_TOAST", toast: {