From a0f67a4da35912e011ddf82b61c46eaac744181b Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Fri, 24 Dec 2021 19:15:00 +0100 Subject: [PATCH] Improve updater --- src/server/main.js | 9 ++++----- src/server/updater.js | 13 +++---------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/server/main.js b/src/server/main.js index edc4b8b..4877204 100644 --- a/src/server/main.js +++ b/src/server/main.js @@ -6,8 +6,6 @@ if (require('electron-squirrel-startup')) { app.quit() return } -require('./updater.js').configUpdater(app, autoUpdater, dialog, logger, showNotification) - const minecraft = require('./minecraft.js') minecraft.showNotification = showNotification @@ -27,7 +25,9 @@ function createWindow () { frame: false }) Menu.setApplicationMenu(null) - win.loadFile('src/client/login.html') + win.loadFile('src/client/login.html').then(() => { + require('./updater.js').configUpdater(app, autoUpdater, dialog, logger, showNotification) + }) win.on("close", () => { app.quit() }) @@ -35,10 +35,9 @@ function createWindow () { const { setWindow, minimizeWindow, closeWindow } = require("./menubar.js"); -setWindow(win) - app.whenReady().then(() => { createWindow() + setWindow(win) }) app.on('window-all-closed', () => { diff --git a/src/server/updater.js b/src/server/updater.js index 4d8989b..72bec7e 100644 --- a/src/server/updater.js +++ b/src/server/updater.js @@ -2,13 +2,6 @@ const isDev = require('electron-is-dev') const pkg = require('../../package.json') const server = 'https://update.electronjs.org' -function initUpdater(autoUpdater) { - autoUpdater.checkForUpdates() - setInterval(() => { - autoUpdater.checkForUpdates() - }, 10 * 60 * 1000) // 10 minutes -} - function configUpdater(app, autoUpdater, dialog, logger, showNotification) { logger.info(`electron version: ${process.versions['electron']}`) logger.info(`chrome version: ${process.versions['chrome']}`) @@ -23,10 +16,10 @@ function configUpdater(app, autoUpdater, dialog, logger, showNotification) { const feed = `${server}/${pkg.repository}/${process.platform}-${process.arch}/${app.getVersion()}` autoUpdater.setFeedURL(feed) - app.isReady ? initUpdater(autoUpdater) : app.on("ready", () => initUpdater(autoUpdater)) - + logger.info("Checking for update...") + autoUpdater.checkForUpdates() - autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => { + autoUpdater.on('update-downloaded', (_event, releaseNotes, releaseName) => { const dialogOpts = { type: 'info', buttons: ['Rédémarrer', 'Plus tard'],