From c7d2545ec7bbcdba30b775453d53df5a359410bd Mon Sep 17 00:00:00 2001
From: crupest <crupest@outlook.com>
Date: Thu, 21 Sep 2023 15:35:27 +0800
Subject: Revert dialog.

---
 FrontEnd/src/pages/timeline/TimelinePostView.tsx | 52 ++++++++++++------------
 1 file changed, 25 insertions(+), 27 deletions(-)

(limited to 'FrontEnd/src/pages/timeline/TimelinePostView.tsx')

diff --git a/FrontEnd/src/pages/timeline/TimelinePostView.tsx b/FrontEnd/src/pages/timeline/TimelinePostView.tsx
index 4f0460ff..2cfe51c4 100644
--- a/FrontEnd/src/pages/timeline/TimelinePostView.tsx
+++ b/FrontEnd/src/pages/timeline/TimelinePostView.tsx
@@ -8,7 +8,7 @@ import {
 import { pushAlert } from "~src/components/alert";
 import { useClickOutside } from "~src/components/hooks";
 import UserAvatar from "~src/components/user/UserAvatar";
-import { DialogProvider, useDialog } from "~src/components/dialog";
+import { useDialog } from "~src/components/dialog";
 import FlatButton from "~src/components/button/FlatButton";
 import ConfirmDialog from "~src/components/dialog/ConfirmDialog";
 import TimelinePostContentView from "./view/TimelinePostContentView";
@@ -32,33 +32,13 @@ export default function TimelinePostView(props: TimelinePostViewProps) {
   const [operationMaskVisible, setOperationMaskVisible] =
     useState<boolean>(false);
 
-  const { controller, switchDialog } = useDialog(
-    {
-      delete: (
-        <ConfirmDialog
-          title="timeline.post.deleteDialog.title"
-          body="timeline.post.deleteDialog.prompt"
-          onConfirm={() => {
-            void getHttpTimelineClient()
-              .deletePost(post.timelineOwnerV2, post.timelineNameV2, post.id)
-              .then(onDeleted, () => {
-                pushAlert({
-                  color: "danger",
-                  message: "timeline.deletePostFailed",
-                });
-              });
-          }}
-        />
-      ),
-    },
-    {
-      onClose: {
-        delete: () => {
-          setOperationMaskVisible(false);
-        },
+  const { switchDialog, dialogPropsMap } = useDialog(["delete"], {
+    onClose: {
+      delete: () => {
+        setOperationMaskVisible(false);
       },
     },
-  );
+  });
 
   const [maskElement, setMaskElement] = useState<HTMLElement | null>(null);
   useClickOutside(maskElement, () => setOperationMaskVisible(false));
@@ -114,10 +94,28 @@ export default function TimelinePostView(props: TimelinePostViewProps) {
                 e.stopPropagation();
               }}
             />
+            <ConfirmDialog
+              title="timeline.post.deleteDialog.title"
+              body="timeline.post.deleteDialog.prompt"
+              onConfirm={() => {
+                void getHttpTimelineClient()
+                  .deletePost(
+                    post.timelineOwnerV2,
+                    post.timelineNameV2,
+                    post.id,
+                  )
+                  .then(onDeleted, () => {
+                    pushAlert({
+                      color: "danger",
+                      message: "timeline.deletePostFailed",
+                    });
+                  });
+              }}
+              {...dialogPropsMap["delete"]}
+            />
           </div>
         ) : null}
       </TimelinePostCard>
-      <DialogProvider controller={controller} />
     </TimelinePostContainer>
   );
 }
-- 
cgit v1.2.3

