From f09208979ab39ac6940c5c649776c3348389d67c Mon Sep 17 00:00:00 2001 From: Oj Date: Fri, 22 Apr 2022 10:11:57 +0100 Subject: [PATCH] [Splash] Add manual host update UI support --- src/splash/index.js | 9 ++++++--- src/splash/preload.js | 4 +++- src/updater/hostUpdater.js | 4 ++-- src/updater/moduleUpdater.js | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/splash/index.js b/src/splash/index.js index 90693ad..54c731b 100644 --- a/src/splash/index.js +++ b/src/splash/index.js @@ -1,4 +1,4 @@ -const { app } = require('electron'); +const { app, ipcMain } = require('electron'); const moduleUpdater = require("../updater/moduleUpdater"); const updater = require("../updater/updater"); @@ -68,6 +68,9 @@ const launchSplash = (startMin) => { if (process.platform !== 'darwin') win.on('closed', () => !launched && app.quit()); + ipcMain.on('ss', launchMain); + ipcMain.on('sq', app.quit); + if (!startMin) win.once('ready-to-show', win.show); }; @@ -216,8 +219,8 @@ const initOld = () => { // "Old" (not v2 / new, win32 only) on('update-manually', e => { - splashState.newVersion = e.newVersion; - sendState('update-manually'); + splashState.details = e.details; + sendState('manual'); }); sendState(CHECKING_FOR_UPDATES); diff --git a/src/splash/preload.js b/src/splash/preload.js index e02f213..b58a6e8 100644 --- a/src/splash/preload.js +++ b/src/splash/preload.js @@ -2,5 +2,7 @@ const { contextBridge, ipcRenderer } = require('electron'); contextBridge.exposeInMainWorld('Splash', { - onState: callback => ipcRenderer.on('state', (_, state) => callback(state)) + onState: callback => ipcRenderer.on('state', (_, state) => callback(state)), + quit: () => ipcRenderer.send('sq'), + skip: () => ipcRenderer.send('ss') }); \ No newline at end of file diff --git a/src/updater/hostUpdater.js b/src/updater/hostUpdater.js index 5cfb1e8..1c2e154 100644 --- a/src/updater/hostUpdater.js +++ b/src/updater/hostUpdater.js @@ -14,12 +14,12 @@ module.exports = process.platform === 'linux' ? new (class HostLinux extends req } async checkForUpdates() { - get(this.url, (e, r) => { + get(this.url, (e, r, b) => { if (e) return this.emit('error'); if (r.statusCode === 204) return this.emit('update-not-available'); - this.emit('update-manually'); + this.emit('update-manually', b); }); } })() : autoUpdater; \ No newline at end of file diff --git a/src/updater/moduleUpdater.js b/src/updater/moduleUpdater.js index f6ec4c4..4cd72dc 100644 --- a/src/updater/moduleUpdater.js +++ b/src/updater/moduleUpdater.js @@ -75,12 +75,12 @@ exports.init = (endpoint, { releaseChannel, version }) => { hostUpdater.on('update-not-available', hostPassed); - hostUpdater.on('update-manually', v => { + hostUpdater.on('update-manually', d => { log('Modules', 'Host manual'); checking = false; events.emit('update-manually', { - newVersion: v + details: d }); events.emit('update-check-finished', {