From 3ee18a8cb3a2893f552275c35b0724daf4b8ab69 Mon Sep 17 00:00:00 2001
From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>
Date: Tue, 22 Oct 2024 12:23:35 +0300
Subject: frontend: await message

---
 frontend/src/hooks/UseMessage.tsx | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

(limited to 'frontend/src/hooks/UseMessage.tsx')

diff --git a/frontend/src/hooks/UseMessage.tsx b/frontend/src/hooks/UseMessage.tsx
index 249a3bf..0d2799c 100644
--- a/frontend/src/hooks/UseMessage.tsx
+++ b/frontend/src/hooks/UseMessage.tsx
@@ -3,18 +3,24 @@ import MessageDialog from "../components/MessageDialog";
 
 const useMessage = () => {
     const [isOpen, setIsOpen] = useState(false);
-
     const [title, setTitle] = useState<string>("");
     const [subtitle, setSubtitle] = useState<string>("");
+    const [resolvePromise, setResolvePromise] = useState<(() => void) | null>(null);
 
     const message = (title: string, subtitle: string) => {
         setIsOpen(true);
         setTitle(title);
         setSubtitle(subtitle);
+        return new Promise<void>((resolve) => {
+            setResolvePromise(() => resolve);
+        })
     };
 
     const handleClose = () => {
         setIsOpen(false);
+        if (resolvePromise) {
+            setResolvePromise(null);
+        }
     };
 
     const MessageDialogComponent = isOpen && (
-- 
cgit v1.2.3

