diff --git a/src/App.vue b/src/App.vue
index 02792c9..1ae4774 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -7,13 +7,9 @@
Hide saltutil.find_job
jobs
- {{
- !evtSource || evtSource.readyState == evtSource.CLOSED
- ? 'Disconnected'
- : evtSource.readyState == evtSource.OPEN
- ? 'Connected'
- : 'Connecting'
- }}
+
+ {{ evtSourceState }}
+
{
console.info('Connected to eventSource.');
- this.$forceUpdate(); // evtSource.readyState won't be detected otherwise
+ this.updateEvtSourceState();
};
this.evtSource.onmessage = (e) => {
@@ -83,8 +80,8 @@ export default class App extends Vue {
if (!this.evtSourceTimeout) {
console.info('Lost eventSource, reconnecting');
console.info(e);
- this.$forceUpdate(); // evtSource.readyState won't be detected otherwise
- this.evtSource.close();
+ this.updateEvtSourceState();
+ this.evtSource?.close();
this.evtSourceTimeout = window.setTimeout(
this.connectEventSource,
1000,
@@ -100,5 +97,28 @@ export default class App extends Vue {
): event is Extract {
return event.splitTag[1] === type;
}
+
+ updateEvtSourceState(): void {
+ this.evtSourceState =
+ !this.evtSource || this.evtSource.readyState == this.evtSource.CLOSED
+ ? 'Disconnected'
+ : this.evtSource.readyState == this.evtSource.OPEN
+ ? 'Connected'
+ : 'Connecting';
+ }
}
+
+