Fix #99410: SocketIO Reconnect Web Interface #104235
@ -28,8 +28,9 @@
|
|||||||
import * as API from '@/manager-api';
|
import * as API from '@/manager-api';
|
||||||
import { getAPIClient } from "@/api-client";
|
import { getAPIClient } from "@/api-client";
|
||||||
import { backendURL } from '@/urls';
|
import { backendURL } from '@/urls';
|
||||||
|
import { useSocketStatus } from '@/stores/socket-status';
|
||||||
|
|
||||||
import ApiSpinner from '@/components/ApiSpinner.vue'
|
import ApiSpinner from '@/components/ApiSpinner.vue';
|
||||||
|
|
||||||
const DEFAULT_FLAMENCO_NAME = "Flamenco";
|
const DEFAULT_FLAMENCO_NAME = "Flamenco";
|
||||||
const DEFAULT_FLAMENCO_VERSION = "unknown";
|
const DEFAULT_FLAMENCO_VERSION = "unknown";
|
||||||
@ -47,6 +48,14 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
window.app = this;
|
window.app = this;
|
||||||
this.fetchManagerInfo();
|
this.fetchManagerInfo();
|
||||||
|
|
||||||
|
const sockStatus = useSocketStatus();
|
||||||
|
this.$watch(() => sockStatus.isConnected, (isConnected) => {
|
||||||
|
if (!isConnected) return;
|
||||||
|
if (!sockStatus.wasEverDisconnected) return;
|
||||||
|
this.socketIOReconnect();
|
||||||
|
});
|
||||||
|
|
||||||
dr.sybren marked this conversation as resolved
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// TODO: also call this when SocketIO reconnects.
|
// TODO: also call this when SocketIO reconnects.
|
||||||
@ -57,6 +66,16 @@ export default {
|
|||||||
this.flamencoVersion = version.version;
|
this.flamencoVersion = version.version;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
socketIOReconnect() {
|
||||||
|
const metaAPI = new API.MetaApi(getAPIClient())
|
||||||
|
metaAPI.getVersion().then((version) => {
|
||||||
|
if (version.name === this.flamencoName && version.version == this.flamencoVersion)
|
||||||
|
return;
|
||||||
|
console.log(`Updated from ${this.flamencoVersion} to ${version.version}`);
|
||||||
dr.sybren marked this conversation as resolved
Outdated
Sybren A. Stüvel
commented
This function shouldn't be called here, as it does too much. It not only fetches the current version, but also writes to Comparing with This function shouldn't be called here, as it does too much. It not only fetches the current version, but also writes to `this.flamencoVersion`. This means that it overwrites the value that you want to compare against.
Comparing with `DEFAULT_FLAMENCO_VERSION` is *always* going to result in a difference, as the Manager will never return the string 'unknown'.
|
|||||||
|
location.reload();
|
||||||
|
});
|
||||||
Sybren A. Stüvel
commented
For debugging, it's better to log both versions here: the one that was stored on the webapp startup, and the one that was found now. That way you can see "upgraded from X to Y" in the JS console. For debugging, it's better to log both versions here: the one that was stored on the webapp startup, and the one that was found now. That way you can see "upgraded from X to Y" in the JS console.
|
|||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user
This should also check
sockStatus.wasEverDisconnected
, otherwise it'll also respond to the initial connection.