From 38b97470556f77f540fc43d9e979aca9237419e6 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Tue, 19 May 2020 11:46:34 +0200 Subject: [PATCH] Add update dialog at app start and change download link to direct link --- resources/js/settings.js | 2 +- src/Config.js | 2 ++ src/main.js | 29 ++++++++++++++++++++++++++--- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/resources/js/settings.js b/resources/js/settings.js index 8903fcd..8827d14 100644 --- a/resources/js/settings.js +++ b/resources/js/settings.js @@ -30,7 +30,7 @@ document.addEventListener('DOMContentLoaded', () => { updateStatus = document.getElementById('update-status'); updateButton = document.getElementById('download-button'); updateButton.addEventListener('click', () => { - shell.openExternal(`https://github.com/ArisuOngaku/tabs/releases/tag/v${updateInfo.version}`) + shell.openExternal(`https://github.com/ArisuOngaku/tabs/releases/download/v${updateInfo.version}/${updateInfo.path}`) .catch(console.error); }); diff --git a/src/Config.js b/src/Config.js index c599f6d..d379bcb 100644 --- a/src/Config.js +++ b/src/Config.js @@ -33,6 +33,8 @@ export default class Config { this.services.push(new Service('welcome', 'Welcome', 'rocket', false, 'https://github.com/ArisuOngaku/tabs', false)); } + this.updateCheckSkip = data.updateCheckSkip; + this.save(); } diff --git a/src/main.js b/src/main.js index 97b934f..578a844 100644 --- a/src/main.js +++ b/src/main.js @@ -1,11 +1,10 @@ import fs from "fs"; import path from "path"; -import {app, BrowserWindow, ipcMain, Menu, shell, Tray} from "electron"; +import {app, BrowserWindow, dialog, ipcMain, Menu, shell, Tray} from "electron"; import Meta from "./Meta"; import Config from "./Config"; import Service from "./Service"; -import {autoUpdater} from "electron-updater"; import Updater from "./Updater"; const resourcesDir = path.resolve(__dirname, '../resources'); @@ -40,7 +39,31 @@ function toggleMainWindow() { async function createWindow() { // Check for updates - await autoUpdater.checkForUpdatesAndNotify(); + updater.checkForUpdates((available, updateInfo) => { + if (available && updateInfo.version !== config.updateCheckSkip) { + dialog.showMessageBox(window, { + message: `Version ${updateInfo.version} of tabs is available. Do you wish to download this update?`, + buttons: [ + 'Cancel', + 'Download', + ], + checkboxChecked: false, + checkboxLabel: `Don't remind me for this version`, + cancelId: 0, + defaultId: 1, + type: 'question' + }).then(e => { + if (e.checkboxChecked) { + console.log('Skipping update check for version', updateInfo.version); + config.updateCheckSkip = updateInfo.version; + config.save(); + } + if (e.response === 1) { + return shell.openExternal(`https://github.com/ArisuOngaku/tabs/releases/download/v${updateInfo.version}/${updateInfo.path}`); + } + }).catch(console.error); + } + }); // System tray console.log('Loading system Tray');