diff --git a/api/health/routes.mjs b/api/health/routes.mjs index 39c57e8..4fdd404 100644 --- a/api/health/routes.mjs +++ b/api/health/routes.mjs @@ -3,6 +3,10 @@ import serial from '../serial/serial.mjs' import encoder from '../encoder/encoder.mjs' export default class HealthRoutes { + constructor(opts = {}) { + Object.assign(this, opts) + } + registerGlobalIo(io, server) { effect(() => { io.io.emit('status', this.getStatus()) @@ -19,6 +23,7 @@ export default class HealthRoutes { getStatus() { return { + version: this.version, serial_running: Boolean(serial.serial.value), serial_display: serial.currentDisplay.value, encoder_running: Boolean(encoder.encoder.value), diff --git a/api/server.mjs b/api/server.mjs index 9aaec0c..25d19c5 100644 --- a/api/server.mjs +++ b/api/server.mjs @@ -29,7 +29,7 @@ export default class Server { static: new StaticRoutes(), encoder: new EncoderRoutes(), serial: new SerialRoutes(), - health: new HealthRoutes(), + health: new HealthRoutes({ version: this.core.version }), serve: new ServeHandler({ root: localUtil.getPathFromRoot('../public'), version: this.core.version, diff --git a/app/api/client.js b/app/api/client.js index 5b0def2..358953c 100644 --- a/app/api/client.js +++ b/app/api/client.js @@ -16,6 +16,9 @@ class Client { this.status = {} this.socket.on('status', status => { + if (this.status.version && status?.version && this.status.version !== status.version) { + window.location.reload(true) + } this.status = status }) this.socket.on('disconnect', this.disconnected.bind(this)) diff --git a/package.json b/package.json index 9bb6f15..9bbf3c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "church_streamer", - "version": "1.0.2", + "version": "1.0.3", "description": "", "main": "index.mjs", "scripts": {