diff --git a/client/js/socket-events/changelog.js b/client/js/socket-events/changelog.js index d647d16e..a952d3ed 100644 --- a/client/js/socket-events/changelog.js +++ b/client/js/socket-events/changelog.js @@ -33,3 +33,7 @@ socket.on("changelog", function(data) { } } }); + +socket.on("changelog:newversion", () => { + store.state.serverConfiguration.isUpdateAvailable = true; +}); diff --git a/src/plugins/changelog.js b/src/plugins/changelog.js index 9c717430..5a64c704 100644 --- a/src/plugins/changelog.js +++ b/src/plugins/changelog.js @@ -90,7 +90,7 @@ function updateVersions(response) { } } -function checkForUpdates() { +function checkForUpdates(manager) { fetch().then((versionData) => { if (!module.exports.isUpdateAvailable) { // Check for updates every 24 hours + random jitter of <3 hours @@ -106,5 +106,8 @@ function checkForUpdates() { versionData.latest.version )} is available. Read more on GitHub: ${versionData.latest.url}` ); + + // Notify all connected clients about the new version + manager.clients.forEach((client) => client.emit("changelog:newversion")); }); } diff --git a/src/server.js b/src/server.js index 4c771f8d..0ae0334f 100644 --- a/src/server.js +++ b/src/server.js @@ -239,9 +239,9 @@ module.exports = function(options = {}) { if (Helper.config.prefetchStorage) { require("./plugins/storage").emptyDir(); } - }); - changelog.checkForUpdates(); + changelog.checkForUpdates(manager); + }); return server; };