More core UI for auto-update

We keep the old dialog flow on Linux, and on Windows and Mac we show a
single dialog when the file is downloaded.
This commit is contained in:
Alex Liebowitz 2017-12-08 07:14:37 -05:00
parent 5fff24b0fb
commit 24ced8ede7
3 changed files with 24 additions and 1 deletions

View file

@ -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';

View file

@ -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() {

View file

@ -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,