diff options
author | crupest <crupest@outlook.com> | 2021-05-17 20:17:25 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-05-17 20:17:25 +0800 |
commit | 256d647719d0a16f3606dbb0bb757569b83fcaa0 (patch) | |
tree | 5a9eab15ce77a53a3bfd031e3d3506ae3935269b | |
parent | 23eeaa05ea9e816ab55c87f47a575b219c4ceaf0 (diff) | |
download | timeline-256d647719d0a16f3606dbb0bb757569b83fcaa0.tar.gz timeline-256d647719d0a16f3606dbb0bb757569b83fcaa0.tar.bz2 timeline-256d647719d0a16f3606dbb0bb757569b83fcaa0.zip |
fix: Only disconnect signalr when connected.
-rw-r--r-- | FrontEnd/src/app/services/timeline.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/FrontEnd/src/app/services/timeline.ts b/FrontEnd/src/app/services/timeline.ts index 2dbd3e4d..b19dcbe9 100644 --- a/FrontEnd/src/app/services/timeline.ts +++ b/FrontEnd/src/app/services/timeline.ts @@ -1,7 +1,7 @@ import { TimelineVisibility } from "@/http/timeline"; import XRegExp from "xregexp"; import { Observable } from "rxjs"; -import { HubConnectionBuilder } from "@microsoft/signalr"; +import { HubConnectionBuilder, HubConnectionState } from "@microsoft/signalr"; import { getHttpToken } from "@/http/common"; @@ -49,9 +49,11 @@ export function getTimelinePostUpdate$( return () => { connection.off("OnTimelinePostChanged", handler); - void connection - .invoke("UnsubscribeTimelinePostChange", timelineName) - .then(() => connection.stop()); + if (connection.state === HubConnectionState.Connected) { + void connection + .invoke("UnsubscribeTimelinePostChange", timelineName) + .then(() => connection.stop()); + } }; }); } |