diff --git a/package.json b/package.json index cea6b4c..3ae662e 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "target": "nsis", "icon": "resources/logo.png", "publisherName": "Alice Gaudon", - "verifyUpdateCodeSignature": "true", + "verifyUpdateCodeSignature": "false", "publish": [ { "provider": "github", diff --git a/src/Application.ts b/src/Application.ts index 16dc94d..e7591d1 100644 --- a/src/Application.ts +++ b/src/Application.ts @@ -3,6 +3,7 @@ import Meta from "./Meta"; import Config from "./Config"; import Updater from "./Updater"; import MainWindow from "./windows/MainWindow"; +import * as os from "os"; export default class Application { private readonly devMode: boolean; @@ -14,7 +15,7 @@ export default class Application { constructor(devMode: boolean) { this.devMode = devMode; this.config = new Config(); - this.updater = new Updater(this.config); + this.updater = new Updater(this.config, this); this.mainWindow = new MainWindow(this); } @@ -26,9 +27,11 @@ export default class Application { this.setupElectronTweaks(); // Check for updates - this.updater.checkAndPromptForUpdates(this.mainWindow.getWindow()).then(() => { - console.log('Update check successful.'); - }).catch(console.error); + if (os.platform() === 'win32') { + this.updater.checkAndPromptForUpdates(this.mainWindow.getWindow()).then(() => { + console.log('Update check successful.'); + }).catch(console.error); + } console.log('App started'); } diff --git a/src/Updater.ts b/src/Updater.ts index 6e82d58..9491be1 100644 --- a/src/Updater.ts +++ b/src/Updater.ts @@ -2,13 +2,16 @@ import {autoUpdater, UpdateInfo} from "electron-updater"; import {dialog, shell} from "electron"; import Config from "./Config"; import BrowserWindow = Electron.BrowserWindow; +import Application from "./Application"; export default class Updater { private readonly config: Config; + private readonly application: Application; private updateInfo?: UpdateInfo; - public constructor(config: Config) { + public constructor(config: Config, application: Application) { this.config = config; + this.application = application; // Configure auto updater autoUpdater.autoDownload = false; @@ -42,10 +45,10 @@ export default class Updater { if (updateInfo && updateInfo.version !== this.config.updateCheckSkip) { const input = await dialog.showMessageBox(mainWindow, { - message: `Version ${updateInfo.version} of tabs is available. Do you wish to download this update?`, + message: `Version ${updateInfo.version} of tabs is available. Do you wish to install this update?`, buttons: [ 'Cancel', - 'Download', + 'Install', ], checkboxChecked: false, checkboxLabel: `Don't remind me for this version`, @@ -61,7 +64,9 @@ export default class Updater { } if (input.response === 1) { - await shell.openExternal(`https://github.com/ArisuOngaku/tabs/releases/download/v${updateInfo.version}/${updateInfo.path}`); + await this.application.stop(); + await autoUpdater.downloadUpdate(); + autoUpdater.quitAndInstall(); } } }