[Splash] Add manual host update UI support

This commit is contained in:
Ducko 2022-04-22 10:11:57 +01:00
parent fd6274bb95
commit f09208979a
4 changed files with 13 additions and 8 deletions

View File

@ -1,4 +1,4 @@
const { app } = require('electron'); const { app, ipcMain } = require('electron');
const moduleUpdater = require("../updater/moduleUpdater"); const moduleUpdater = require("../updater/moduleUpdater");
const updater = require("../updater/updater"); const updater = require("../updater/updater");
@ -68,6 +68,9 @@ const launchSplash = (startMin) => {
if (process.platform !== 'darwin') win.on('closed', () => !launched && app.quit()); 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); 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 => { on('update-manually', e => {
splashState.newVersion = e.newVersion; splashState.details = e.details;
sendState('update-manually'); sendState('manual');
}); });
sendState(CHECKING_FOR_UPDATES); sendState(CHECKING_FOR_UPDATES);

View File

@ -2,5 +2,7 @@ const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('Splash', { 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')
}); });

View File

@ -14,12 +14,12 @@ module.exports = process.platform === 'linux' ? new (class HostLinux extends req
} }
async checkForUpdates() { async checkForUpdates() {
get(this.url, (e, r) => { get(this.url, (e, r, b) => {
if (e) return this.emit('error'); if (e) return this.emit('error');
if (r.statusCode === 204) return this.emit('update-not-available'); if (r.statusCode === 204) return this.emit('update-not-available');
this.emit('update-manually'); this.emit('update-manually', b);
}); });
} }
})() : autoUpdater; })() : autoUpdater;

View File

@ -75,12 +75,12 @@ exports.init = (endpoint, { releaseChannel, version }) => {
hostUpdater.on('update-not-available', hostPassed); hostUpdater.on('update-not-available', hostPassed);
hostUpdater.on('update-manually', v => { hostUpdater.on('update-manually', d => {
log('Modules', 'Host manual'); log('Modules', 'Host manual');
checking = false; checking = false;
events.emit('update-manually', { events.emit('update-manually', {
newVersion: v details: d
}); });
events.emit('update-check-finished', { events.emit('update-check-finished', {