From 3960e6a7130d03b3c3e8f1e9dd9656727217bfaf Mon Sep 17 00:00:00 2001
From: crupest <crupest@outlook.com>
Date: Sun, 16 May 2021 17:50:12 +0800
Subject: feat: Listen to post update.

---
 .../src/app/views/timeline-common/TimelinePageTemplate.tsx   | 12 ++++++++++++
 1 file changed, 12 insertions(+)

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

diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx
index 81a3c179..4c0cc8e3 100644
--- a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx
+++ b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx
@@ -12,6 +12,7 @@ import TimelinePostEdit from "./TimelinePostEdit";
 
 import useReverseScrollPositionRemember from "@/utilities/useReverseScrollPositionRemember";
 import { generatePalette, setPalette } from "@/palette";
+import { getTimelinePostUpdate as getTimelinePostUpdate$ } from "@/services/timeline";
 
 export interface TimelinePageCardProps {
   timeline: HttpTimelineInfo;
@@ -91,6 +92,17 @@ const TimelinePageTemplate: React.FC<TimelinePageTemplateProps> = (props) => {
     setTimelineReloadKey((old) => old + 1);
   };
 
+  React.useEffect(() => {
+    const timelinePostUpdate$ = getTimelinePostUpdate$(timelineName);
+    const subscription = timelinePostUpdate$.subscribe(() => {
+      setTimelineReloadKey((old) => old + 1);
+    });
+
+    return () => {
+      subscription.unsubscribe();
+    };
+  }, [timelineName]);
+
   const onPostEditHeightChange = React.useCallback((height: number): void => {
     setBottomSpaceHeight(height);
     if (height === 0) {
-- 
cgit v1.2.3

