Notify all connected clients when new version is available

This commit is contained in:
Pavel Djundik 2020-01-17 12:17:37 +02:00
parent 3f928d8742
commit d5ac13f91c
3 changed files with 10 additions and 3 deletions

View file

@ -33,3 +33,7 @@ socket.on("changelog", function(data) {
} }
} }
}); });
socket.on("changelog:newversion", () => {
store.state.serverConfiguration.isUpdateAvailable = true;
});

View file

@ -90,7 +90,7 @@ function updateVersions(response) {
} }
} }
function checkForUpdates() { function checkForUpdates(manager) {
fetch().then((versionData) => { fetch().then((versionData) => {
if (!module.exports.isUpdateAvailable) { if (!module.exports.isUpdateAvailable) {
// Check for updates every 24 hours + random jitter of <3 hours // Check for updates every 24 hours + random jitter of <3 hours
@ -106,5 +106,8 @@ function checkForUpdates() {
versionData.latest.version versionData.latest.version
)} is available. Read more on GitHub: ${versionData.latest.url}` )} 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"));
}); });
} }

View file

@ -239,9 +239,9 @@ module.exports = function(options = {}) {
if (Helper.config.prefetchStorage) { if (Helper.config.prefetchStorage) {
require("./plugins/storage").emptyDir(); require("./plugins/storage").emptyDir();
} }
});
changelog.checkForUpdates(); changelog.checkForUpdates(manager);
});
return server; return server;
}; };