aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-05-17 20:17:25 +0800
committercrupest <crupest@outlook.com>2021-05-17 20:17:25 +0800
commit256d647719d0a16f3606dbb0bb757569b83fcaa0 (patch)
tree5a9eab15ce77a53a3bfd031e3d3506ae3935269b
parent23eeaa05ea9e816ab55c87f47a575b219c4ceaf0 (diff)
downloadtimeline-256d647719d0a16f3606dbb0bb757569b83fcaa0.tar.gz
timeline-256d647719d0a16f3606dbb0bb757569b83fcaa0.tar.bz2
timeline-256d647719d0a16f3606dbb0bb757569b83fcaa0.zip
fix: Only disconnect signalr when connected.
-rw-r--r--FrontEnd/src/app/services/timeline.ts10
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());
+ }
};
});
}