aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src
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
commit4ded8b1df25da8df12098ab462b93dcaefd5b3cf (patch)
treee8f0d1e67724bde76b9839c614079b22c35733b2 /FrontEnd/src
parent8437bc6a0b5a91856b486e9824ea0faece93f26e (diff)
downloadtimeline-4ded8b1df25da8df12098ab462b93dcaefd5b3cf.tar.gz
timeline-4ded8b1df25da8df12098ab462b93dcaefd5b3cf.tar.bz2
timeline-4ded8b1df25da8df12098ab462b93dcaefd5b3cf.zip
fix: Only disconnect signalr when connected.
Diffstat (limited to 'FrontEnd/src')
-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());
+ }
};
});
}