Add back "Upgrade App" button on Mac/Win with different dialog on click
This commit is contained in:
parent
0c8ba50207
commit
f244f9035b
10 changed files with 94 additions and 6 deletions
|
@ -5,13 +5,14 @@ import { selectIsBackDisabled, selectIsForwardDisabled } from 'redux/selectors/n
|
|||
import { selectBalance } from 'redux/selectors/wallet';
|
||||
import { doNavigate, doHistoryBack, doHistoryForward } from 'redux/actions/navigation';
|
||||
import Header from './view';
|
||||
import { selectIsUpgradeAvailable } from 'redux/selectors/app';
|
||||
import { doDownloadUpgrade } from 'redux/actions/app';
|
||||
import { selectIsUpgradeAvailable, selectAutoUpdateDownloaded } from 'redux/selectors/app';
|
||||
import { doDownloadUpgradeRequested } from 'redux/actions/app';
|
||||
|
||||
const select = state => ({
|
||||
isBackDisabled: selectIsBackDisabled(state),
|
||||
isForwardDisabled: selectIsForwardDisabled(state),
|
||||
isUpgradeAvailable: selectIsUpgradeAvailable(state),
|
||||
autoUpdateDownloaded: selectAutoUpdateDownloaded(state),
|
||||
balance: formatCredits(selectBalance(state) || 0, 2),
|
||||
});
|
||||
|
||||
|
@ -19,7 +20,7 @@ const perform = dispatch => ({
|
|||
navigate: path => dispatch(doNavigate(path)),
|
||||
back: () => dispatch(doHistoryBack()),
|
||||
forward: () => dispatch(doHistoryForward()),
|
||||
downloadUpgrade: () => dispatch(doDownloadUpgrade()),
|
||||
downloadUpgradeRequested: () => dispatch(doDownloadUpgradeRequested()),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(Header);
|
||||
|
|
|
@ -10,8 +10,9 @@ export const Header = props => {
|
|||
isBackDisabled,
|
||||
isForwardDisabled,
|
||||
isUpgradeAvailable,
|
||||
autoUpdateDownloaded,
|
||||
navigate,
|
||||
downloadUpgrade,
|
||||
downloadUpgradeRequested,
|
||||
} = props;
|
||||
return (
|
||||
<header id="header">
|
||||
|
@ -86,9 +87,9 @@ export const Header = props => {
|
|||
title={__('Settings')}
|
||||
/>
|
||||
</div>
|
||||
{isUpgradeAvailable && (
|
||||
{(autoUpdateDownloaded || (process.platform === 'linux' && isUpgradeAvailable)) && (
|
||||
<Link
|
||||
onClick={() => downloadUpgrade()}
|
||||
onClick={() => downloadUpgradeRequested()}
|
||||
button="primary button--flat"
|
||||
icon="icon-arrow-up"
|
||||
label={__('Upgrade App')}
|
||||
|
|
|
@ -28,6 +28,7 @@ export const UPDATE_VERSION = 'UPDATE_VERSION';
|
|||
export const UPDATE_REMOTE_VERSION = 'UPDATE_REMOTE_VERSION';
|
||||
export const SKIP_UPGRADE = 'SKIP_UPGRADE';
|
||||
export const START_UPGRADE = 'START_UPGRADE';
|
||||
export const AUTO_UPDATE_DOWNLOADED = 'AUTO_UPDATE_DOWNLOADED';
|
||||
|
||||
// Wallet
|
||||
export const GET_NEW_ADDRESS_STARTED = 'GET_NEW_ADDRESS_STARTED';
|
||||
|
|
|
@ -3,6 +3,7 @@ export const INCOMPATIBLE_DAEMON = 'incompatibleDaemon';
|
|||
export const FILE_TIMEOUT = 'file_timeout';
|
||||
export const DOWNLOADING = 'downloading';
|
||||
export const AUTO_UPDATE_DOWNLOADED = "auto_update_downloaded";
|
||||
export const AUTO_UPDATE_CONFIRM = 'auto_update_confirm';
|
||||
export const ERROR = 'error';
|
||||
export const INSUFFICIENT_CREDITS = 'insufficient_credits';
|
||||
export const UPGRADE = 'upgrade';
|
||||
|
|
10
src/renderer/modal/modalAutoUpdateConfirm/index.js
Normal file
10
src/renderer/modal/modalAutoUpdateConfirm/index.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { doCloseModal } from "redux/actions/app";
|
||||
import ModalAutoUpdateConfirm from "./view";
|
||||
|
||||
const perform = dispatch => ({
|
||||
closeModal: () => dispatch(doCloseModal()),
|
||||
});
|
||||
|
||||
export default connect(null, perform)(ModalAutoUpdateConfirm);
|
39
src/renderer/modal/modalAutoUpdateConfirm/view.jsx
Normal file
39
src/renderer/modal/modalAutoUpdateConfirm/view.jsx
Normal file
|
@ -0,0 +1,39 @@
|
|||
import React from "react";
|
||||
import { Modal } from "modal/modal";
|
||||
import { Line } from "rc-progress";
|
||||
import Link from "component/link/index";
|
||||
|
||||
const { ipcRenderer } = require("electron");
|
||||
|
||||
class ModalAutoUpdateConfirm extends React.PureComponent {
|
||||
render() {
|
||||
const { closeModal } = this.props;
|
||||
|
||||
return (
|
||||
<Modal
|
||||
isOpen={true}
|
||||
type="confirm"
|
||||
contentLabel={__("Update Downloaded")}
|
||||
confirmButtonLabel={__("Upgrade")}
|
||||
abortButtonLabel={__("Now now")}
|
||||
onConfirmed={() => {
|
||||
ipcRenderer.send("autoUpdateAccepted");
|
||||
}}
|
||||
onAborted={() => {
|
||||
closeModal();
|
||||
}}
|
||||
>
|
||||
<section>
|
||||
<h3 className="text-center">{__("LBRY Update Ready")}</h3>
|
||||
<p>
|
||||
{__(
|
||||
'Your LBRY update is ready. Restart LBRY now to use it!'
|
||||
)}
|
||||
</p>
|
||||
</section>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default ModalAutoUpdateConfirm;
|
|
@ -3,6 +3,7 @@ import ModalError from 'modal/modalError';
|
|||
import ModalAuthFailure from 'modal/modalAuthFailure';
|
||||
import ModalDownloading from 'modal/modalDownloading';
|
||||
import ModalAutoUpdateDownloaded from "modal/modalAutoUpdateDownloaded";
|
||||
import ModalAutoUpdateConfirm from "modal/modalAutoUpdateDownloaded";
|
||||
import ModalUpgrade from 'modal/modalUpgrade';
|
||||
import ModalWelcome from 'modal/modalWelcome';
|
||||
import ModalFirstReward from 'modal/modalFirstReward';
|
||||
|
@ -105,6 +106,8 @@ class ModalRouter extends React.PureComponent {
|
|||
return <ModalDownloading {...modalProps} />;
|
||||
case modals.AUTO_UPDATE_DOWNLOADED:
|
||||
return <ModalAutoUpdateDownloaded {...modalProps} />;
|
||||
case modals.AUTO_UPDATE_CONFIRM:
|
||||
return <ModalAutoUpdateConfirm {...modalProps} />;
|
||||
case modals.ERROR:
|
||||
return <ModalError {...modalProps} />;
|
||||
case modals.FILE_TIMEOUT:
|
||||
|
|
|
@ -67,6 +67,26 @@ export function doStartUpgrade() {
|
|||
};
|
||||
}
|
||||
|
||||
export function doDownloadUpgradeRequested() {
|
||||
// This means the user requested an upgrade by clicking the "upgrade" button in the navbar.
|
||||
// If on Mac and Windows, we do some new behavior for the auto-update system.
|
||||
// This will probably be reorganized once we get auto-update going on Linux and remove
|
||||
// the old logic.
|
||||
|
||||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
|
||||
if (['win32', 'darwin'].includes(process.platform)) { // electron-updater behavior
|
||||
dispatch({
|
||||
type: ACTIONS.OPEN_MODAL,
|
||||
data: { modal: MODALS.AUTO_UPDATE_CONFIRM },
|
||||
});
|
||||
} else { // Old behavior for Linux
|
||||
doDownloadUpgrade();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function doDownloadUpgrade() {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
|
@ -109,6 +129,10 @@ export function doDownloadUpgrade() {
|
|||
export function doAutoUpdate() {
|
||||
return function(dispatch, getState) {
|
||||
const state = getState();
|
||||
dispatch({
|
||||
type: ACTIONS.AUTO_UPDATE_DOWNLOADED,
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: ACTIONS.OPEN_MODAL,
|
||||
data: { modal: MODALS.AUTO_UPDATE_DOWNLOADED },
|
||||
|
|
|
@ -46,6 +46,7 @@ const defaultState: AppState = {
|
|||
hasSignature: false,
|
||||
badgeNumber: 0,
|
||||
volume: Number(sessionStorage.getItem('volume')) || 1,
|
||||
autoUpdateDownloaded: false,
|
||||
|
||||
downloadProgress: undefined,
|
||||
upgradeDownloading: undefined,
|
||||
|
@ -79,6 +80,11 @@ reducers[ACTIONS.UPGRADE_CANCELLED] = state =>
|
|||
modal: null,
|
||||
});
|
||||
|
||||
reducers[ACTIONS.AUTO_UPDATE_DOWNLOADED] = state =>
|
||||
Object.assign({}, state, {
|
||||
autoUpdateDownloaded: true,
|
||||
});
|
||||
|
||||
reducers[ACTIONS.UPGRADE_DOWNLOAD_COMPLETED] = (state, action) =>
|
||||
Object.assign({}, state, {
|
||||
downloadPath: action.data.path,
|
||||
|
|
|
@ -56,6 +56,8 @@ export const selectUpgradeDownloadPath = createSelector(selectState, state => st
|
|||
|
||||
export const selectUpgradeDownloadItem = createSelector(selectState, state => state.downloadItem);
|
||||
|
||||
export const selectAutoUpdateDownloaded = createSelector(selectState, state => state.autoUpdateDownloaded);
|
||||
|
||||
export const selectModalProps = createSelector(selectState, state => state.modalProps);
|
||||
|
||||
export const selectDaemonVersionMatched = createSelector(
|
||||
|
|
Loading…
Add table
Reference in a new issue