From c3cf26a7788d97135e0f2a3e247e6cbe6b1b9664 Mon Sep 17 00:00:00 2001
From: crupest <crupest@outlook.com>
Date: Tue, 19 Jan 2021 16:23:27 +0800
Subject: ...

---
 FrontEnd/src/app/views/timeline-common/Timeline.tsx | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

(limited to 'FrontEnd/src/app/views/timeline-common/Timeline.tsx')

diff --git a/FrontEnd/src/app/views/timeline-common/Timeline.tsx b/FrontEnd/src/app/views/timeline-common/Timeline.tsx
index 2446c0dd..288be141 100644
--- a/FrontEnd/src/app/views/timeline-common/Timeline.tsx
+++ b/FrontEnd/src/app/views/timeline-common/Timeline.tsx
@@ -6,11 +6,12 @@ import {
   TimelinePostInfo,
   timelineService,
 } from "@/services/timeline";
+import { useUser } from "@/services/user";
+import { pushAlert } from "@/services/alert";
 
 import TimelineItem from "./TimelineItem";
 import TimelineTop from "./TimelineTop";
 import TimelineDateItem from "./TimelineDateItem";
-import { useUser } from "@/services/user";
 
 function dateEqual(left: Date, right: Date): boolean {
   return (
@@ -25,7 +26,6 @@ export interface TimelineProps {
   style?: React.CSSProperties;
   timeline: TimelineInfo;
   posts: TimelinePostInfo[];
-  onDelete: (post: TimelinePostInfo) => void;
 }
 
 const Timeline: React.FC<TimelineProps> = (props) => {
@@ -87,7 +87,17 @@ const Timeline: React.FC<TimelineProps> = (props) => {
                               old === post.index ? -1 : post.index
                             ),
                           onDelete: () => {
-                            props.onDelete(post);
+                            timelineService
+                              .deletePost(timeline.name, post.id)
+                              .catch(() => {
+                                pushAlert({
+                                  type: "danger",
+                                  message: {
+                                    type: "i18n",
+                                    key: "timeline.deletePostFailed",
+                                  },
+                                });
+                              });
                           },
                         }
                       : undefined
-- 
cgit v1.2.3

