From 3957bf2afc7aaa614824d28dd06826049d9c2e3f Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Sun, 10 Dec 2017 03:06:30 -0500 Subject: [PATCH] Finish core UI for auto update --- src/main/index.js | 3 --- src/renderer/constants/action_types.js | 1 - src/renderer/index.js | 14 ++++++++++++++ .../modal/modalAutoUpdateDownloaded/view.jsx | 7 ++++--- src/renderer/redux/actions/app.js | 2 +- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index 1dfb4145b..e4c3e1ffb 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -436,9 +436,6 @@ app.on('before-quit', event => { shutdownDaemonAndQuit(); } else { console.log('Quitting.'); - if (autoUpdating) { - minimize = false; - } } }); diff --git a/src/renderer/constants/action_types.js b/src/renderer/constants/action_types.js index f09e13167..3c828f5cb 100644 --- a/src/renderer/constants/action_types.js +++ b/src/renderer/constants/action_types.js @@ -19,7 +19,6 @@ export const DOWNLOAD_UPGRADE = 'DOWNLOAD_UPGRADE'; export const UPGRADE_DOWNLOAD_STARTED = 'UPGRADE_DOWNLOAD_STARTED'; export const UPGRADE_DOWNLOAD_COMPLETED = 'UPGRADE_DOWNLOAD_COMPLETED'; export const UPGRADE_DOWNLOAD_PROGRESSED = 'UPGRADE_DOWNLOAD_PROGRESSED'; -export const AUTO_UPDATE_DOWNLOAD_COMPLETED = "AUTO_UPDATE_DOWNLOAD_COMPLETED"; export const CHECK_UPGRADE_AVAILABLE = 'CHECK_UPGRADE_AVAILABLE'; export const CHECK_UPGRADE_START = 'CHECK_UPGRADE_START'; export const CHECK_UPGRADE_SUCCESS = 'CHECK_UPGRADE_SUCCESS'; diff --git a/src/renderer/index.js b/src/renderer/index.js index d7152880a..cafd41c35 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -20,6 +20,8 @@ import app from './app'; const { autoUpdater } = remote.require('electron-updater'); const { contextMenu } = remote.require('./main.js'); +autoUpdater.logger = remote.require("electron-log"); + window.addEventListener('contextmenu', event => { contextMenu(remote.getCurrentWindow(), event.x, event.y, app.env === 'development'); event.preventDefault(); @@ -102,6 +104,18 @@ const init = () => { app.store.dispatch(doAutoUpdate()); }); + if (["win32", "darwin"].includes(process.platform)) { + autoUpdater.on("update-available", () => { + console.log("Update available"); + }); + autoUpdater.on("update-not-available", () => { + console.log("Update not available"); + }); + autoUpdater.on("update-downloaded", () => { + console.log("Update downloaded"); + app.store.dispatch(doAutoUpdate()); + }); + } app.store.dispatch(doDownloadLanguages()); function onDaemonReady() { diff --git a/src/renderer/modal/modalAutoUpdateDownloaded/view.jsx b/src/renderer/modal/modalAutoUpdateDownloaded/view.jsx index 46803c645..2d136071a 100644 --- a/src/renderer/modal/modalAutoUpdateDownloaded/view.jsx +++ b/src/renderer/modal/modalAutoUpdateDownloaded/view.jsx @@ -3,8 +3,7 @@ import { Modal } from "modal/modal"; import { Line } from "rc-progress"; import Link from "component/link/index"; -const { remote } = require("electron"); -const { autoUpdater } = remote.require("electron-updater"); +const { ipcRenderer } = require("electron"); class ModalAutoUpdateDownloaded extends React.PureComponent { render() { @@ -13,7 +12,9 @@ class ModalAutoUpdateDownloaded extends React.PureComponent { isOpen={true} contentLabel={__("Update downloaded")} confirmButtonLabel={__("Update and Restart")} - onConfirmed={autoUpdater.quitAndInstall()} + onConfirmed={() => { + ipcRenderer.send("autoUpdate"); + }} >

{__("LBRY Leveled Up")}

diff --git a/src/renderer/redux/actions/app.js b/src/renderer/redux/actions/app.js index 26eb5bd7b..e2b36470b 100644 --- a/src/renderer/redux/actions/app.js +++ b/src/renderer/redux/actions/app.js @@ -111,7 +111,7 @@ export function doAutoUpdate() { const state = getState(); dispatch({ type: types.OPEN_MODAL, - data: modals.AUTO_UPDATE_DOWNLOADED, + data: { modal: modals.AUTO_UPDATE_DOWNLOADED }, }); }; }