diff --git a/src/renderer/constants/action_types.js b/src/renderer/constants/action_types.js index 3c828f5cb..f09e13167 100644 --- a/src/renderer/constants/action_types.js +++ b/src/renderer/constants/action_types.js @@ -19,6 +19,7 @@ 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 fd6dcc1f7..d7152880a 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -9,7 +9,7 @@ import lbry from 'lbry'; import React from 'react'; import ReactDOM from 'react-dom'; import { Provider } from 'react-redux'; -import { doConditionalAuthNavigate, doDaemonReady, doShowSnackBar } from 'redux/actions/app'; +import { doConditionalAuthNavigate, doDaemonReady, doShowSnackBar, doAutoUpdate } from 'redux/actions/app'; import { doNavigate } from 'redux/actions/navigation'; import { doDownloadLanguages } from 'redux/actions/settings'; import { doUserEmailVerify } from 'redux/actions/user'; @@ -17,6 +17,7 @@ import 'scss/all.scss'; import store from 'store'; import app from './app'; +const { autoUpdater } = remote.require('electron-updater'); const { contextMenu } = remote.require('./main.js'); window.addEventListener('contextmenu', event => { @@ -97,6 +98,10 @@ document.addEventListener('click', event => { }); const init = () => { + autoUpdater.on("update-downloaded", () => { + app.store.dispatch(doAutoUpdate()); + }); + app.store.dispatch(doDownloadLanguages()); function onDaemonReady() { diff --git a/src/renderer/redux/actions/app.js b/src/renderer/redux/actions/app.js index 2ecc1dcaf..26eb5bd7b 100644 --- a/src/renderer/redux/actions/app.js +++ b/src/renderer/redux/actions/app.js @@ -20,6 +20,7 @@ import { selectUpgradeFilename, } from 'redux/selectors/app'; +const { autoUpdater } = remote.require('electron-updater'); const { download } = remote.require('electron-dl'); const Fs = remote.require('fs'); const { lbrySettings: config } = require('package.json'); @@ -105,6 +106,16 @@ export function doDownloadUpgrade() { }; } +export function doAutoUpdate() { + return function(dispatch, getState) { + const state = getState(); + dispatch({ + type: types.OPEN_MODAL, + data: modals.AUTO_UPDATE_DOWNLOADED, + }); + }; +} + export function doCancelUpgrade() { return (dispatch, getState) => { const state = getState(); @@ -135,6 +146,12 @@ export function doCheckUpgradeAvailable() { type: ACTIONS.CHECK_UPGRADE_START, }); + if (["win32", "darwin"].includes(process.platform)) { + // On Windows and Mac, updates happen silently + autoUpdater.checkForUpdates(); + return; + } + const success = ({ remoteVersion, upgradeAvailable }) => { dispatch({ type: ACTIONS.CHECK_UPGRADE_SUCCESS,