aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/app/views/timeline-common/Timeline.tsx
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-05-16 19:56:05 +0800
committercrupest <crupest@outlook.com>2021-05-16 19:56:05 +0800
commit04737cd734eda58eca5da59d5a6a35c0dc1e9364 (patch)
tree0a1ba6761e1f59255a34e22782f1af7ad4c92c02 /FrontEnd/src/app/views/timeline-common/Timeline.tsx
parent37fa764e9f23e058766bd444ce4e2e3806a1dcc2 (diff)
downloadtimeline-04737cd734eda58eca5da59d5a6a35c0dc1e9364.tar.gz
timeline-04737cd734eda58eca5da59d5a6a35c0dc1e9364.tar.bz2
timeline-04737cd734eda58eca5da59d5a6a35c0dc1e9364.zip
fix: Enhance logic of signalr.
Diffstat (limited to 'FrontEnd/src/app/views/timeline-common/Timeline.tsx')
-rw-r--r--FrontEnd/src/app/views/timeline-common/Timeline.tsx14
1 files changed, 14 insertions, 0 deletions
diff --git a/FrontEnd/src/app/views/timeline-common/Timeline.tsx b/FrontEnd/src/app/views/timeline-common/Timeline.tsx
index 32d0bdd5..8bdf4d3b 100644
--- a/FrontEnd/src/app/views/timeline-common/Timeline.tsx
+++ b/FrontEnd/src/app/views/timeline-common/Timeline.tsx
@@ -7,6 +7,8 @@ import {
} from "@/http/common";
import { getHttpTimelineClient, HttpTimelinePostInfo } from "@/http/timeline";
+import { getTimelinePostUpdate$ } from "@/services/timeline";
+
import TimelinePagedPostListView from "./TimelinePagedPostListView";
import TimelineTop from "./TimelineTop";
import TimelineLoading from "./TimelineLoading";
@@ -34,6 +36,18 @@ const Timeline: React.FC<TimelineProps> = (props) => {
}, [timelineName]);
React.useEffect(() => {
+ if (timelineName != null && state === "loaded") {
+ const timelinePostUpdate$ = getTimelinePostUpdate$(timelineName);
+ const subscription = timelinePostUpdate$.subscribe(() => {
+ onReload();
+ });
+ return () => {
+ subscription.unsubscribe();
+ };
+ }
+ }, [timelineName, state, onReload]);
+
+ React.useEffect(() => {
if (timelineName != null) {
let subscribe = true;