From a89c390658cc6cad3f5eb34ee3fa78c53526a720 Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Thu, 19 Jul 2018 12:07:16 +0300 Subject: [PATCH] feat(portative): display message about update in portative version #41 --- src/background/background.js | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/background/background.js b/src/background/background.js index b8b35448..6c6c85c5 100644 --- a/src/background/background.js +++ b/src/background/background.js @@ -6,7 +6,7 @@ import path from "path"; import url from "url"; import os from 'os'; -import { app, Menu, ipcMain, Tray, dialog } from "electron"; +import { app, Menu, ipcMain, Tray, dialog, shell } from "electron"; import createWindow from "./helpers/window"; import { autoUpdater } from 'electron-updater' @@ -220,14 +220,40 @@ app.on("ready", () => { } }) - if (env.name === "production" && !portative) { + if (env.name === "production") { checkInternet(enabled => { if(!enabled) { console.log('no internet connection were founded, updater not started') return } - autoUpdater.checkForUpdates() + + if(portative) + { + autoUpdater.getUpdateInfo().then(info => { + if(info.version == app.getVersion()) + { + console.log('update not founded for version', app.getVersion()) + return + } + + dialog.showMessageBox({ + type: 'info', + title: 'Found Updates', + message: 'Found updates to version ' + info.version + '. Open page to download manually?', + buttons: ['Open', 'Dont update'] + }, (buttonIndex) => { + if (buttonIndex === 0) { + shell.openExternal('https://github.com/DEgITx/rats-search/releases') + } + }) + }) + } + else + { + // full version, just download update + autoUpdater.checkForUpdates() + } }) }