Refactor ModalAutoUpdateConfirm into ModalAutoUpdateDownloaded

This commit is contained in:
JakeVdub 2019-10-02 17:57:11 -05:00 committed by Sean Yesmunt
parent 2349c48ce8
commit de5498f1b8
6 changed files with 4 additions and 75 deletions

View file

@ -5,7 +5,6 @@ export const FILE_TIMEOUT = 'file_timeout';
export const DOWNLOADING = 'downloading';
export const AUTO_GENERATE_THUMBNAIL = 'auto_generate_thumbnail';
export const AUTO_UPDATE_DOWNLOADED = 'auto_update_downloaded';
export const AUTO_UPDATE_CONFIRM = 'auto_update_confirm';
export const ERROR = 'error';
export const UPGRADE = 'upgrade';
export const WELCOME = 'welcome';

View file

@ -1,13 +0,0 @@
import { connect } from 'react-redux';
import { doAutoUpdateDeclined, doHideModal } from 'redux/actions/app';
import ModalAutoUpdateConfirm from './view';
const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()),
declineAutoUpdate: () => dispatch(doAutoUpdateDeclined()),
});
export default connect(
null,
perform
)(ModalAutoUpdateConfirm);

View file

@ -1,42 +0,0 @@
// @flow
import React from 'react';
import { Modal } from 'modal/modal';
import Button from 'component/button';
import { ipcRenderer } from 'electron';
type Props = {
closeModal: () => void,
declineAutoUpdate: () => void,
};
class ModalAutoUpdateConfirm extends React.PureComponent<Props> {
render() {
const { closeModal, declineAutoUpdate } = this.props;
return (
<Modal
isOpen
type="confirm"
contentLabel={__('Upgrade Downloaded')}
title={__('LBRY Upgrade Ready')}
confirmButtonLabel={__('Upgrade')}
abortButtonLabel={__('Not now')}
onConfirmed={() => {
ipcRenderer.send('autoUpdateAccepted');
}}
onAborted={() => {
declineAutoUpdate();
closeModal();
}}
>
<p>{__('Your LBRY upgrade is ready. Restart LBRY now to use it!')}</p>
<p className="help">
{__('Want to know what has changed?')} See the{' '}
<Button button="link" label={__('release notes')} href="https://github.com/lbryio/lbry-desktop/releases" />.
</p>
</Modal>
);
}
}
export default ModalAutoUpdateConfirm;

View file

@ -33,8 +33,8 @@ class ModalAutoUpdateDownloaded extends React.PureComponent<Props, State> {
type="confirm"
contentLabel={__('Upgrade Downloaded')}
title={__('LBRY Leveled Up')}
confirmButtonLabel={__('Use Now')}
abortButtonLabel={__('Upgrade on Close')}
confirmButtonLabel={__('Upgrade Now')}
abortButtonLabel={__('Not now')}
confirmButtonDisabled={this.state.disabled}
onConfirmed={() => {
this.setState({ disabled: true });
@ -42,7 +42,6 @@ class ModalAutoUpdateDownloaded extends React.PureComponent<Props, State> {
}}
onAborted={() => {
declineAutoUpdate();
ipcRenderer.send('autoUpdateDeclined');
closeModal();
}}
>

View file

@ -5,7 +5,6 @@ import ModalError from 'modal/modalError';
import ModalDownloading from 'modal/modalDownloading';
import ModalAutoGenerateThumbnail from 'modal/modalAutoGenerateThumbnail';
import ModalAutoUpdateDownloaded from 'modal/modalAutoUpdateDownloaded';
import ModalAutoUpdateConfirm from 'modal/modalAutoUpdateConfirm';
import ModalUpgrade from 'modal/modalUpgrade';
import ModalWelcome from 'modal/modalWelcome';
import ModalFirstReward from 'modal/modalFirstReward';
@ -56,8 +55,6 @@ function ModalRouter(props: Props) {
return <ModalAutoGenerateThumbnail {...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:

View file

@ -133,21 +133,10 @@ export function doDownloadUpgradeRequested() {
// This will probably be reorganized once we get auto-update going on Linux and remove
// the old logic.
return (dispatch, getState) => {
const state = getState();
const autoUpdateDeclined = selectAutoUpdateDeclined(state);
return dispatch => {
if (['win32', 'darwin'].includes(process.platform)) {
// electron-updater behavior
if (autoUpdateDeclined) {
// The user declined an update before, so show the "confirm" dialog
dispatch(doOpenModal(MODALS.AUTO_UPDATE_CONFIRM));
} else {
// The user was never shown the original update dialog (e.g. because they were
// watching a video). So show the inital "update downloaded" dialog.
dispatch(doOpenModal(MODALS.AUTO_UPDATE_DOWNLOADED));
}
} else {
// Old behavior for Linux
dispatch(doDownloadUpgrade());