From 4ded8b1df25da8df12098ab462b93dcaefd5b3cf Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 17 May 2021 20:17:25 +0800 Subject: fix: Only disconnect signalr when connected. --- FrontEnd/src/app/services/timeline.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'FrontEnd/src') 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()); + } }; }); } -- cgit v1.2.3