Refactor ModalAutoUpdateConfirm into ModalAutoUpdateDownloaded
This commit is contained in:
parent
2349c48ce8
commit
de5498f1b8
6 changed files with 4 additions and 75 deletions
|
@ -5,7 +5,6 @@ export const FILE_TIMEOUT = 'file_timeout';
|
||||||
export const DOWNLOADING = 'downloading';
|
export const DOWNLOADING = 'downloading';
|
||||||
export const AUTO_GENERATE_THUMBNAIL = 'auto_generate_thumbnail';
|
export const AUTO_GENERATE_THUMBNAIL = 'auto_generate_thumbnail';
|
||||||
export const AUTO_UPDATE_DOWNLOADED = 'auto_update_downloaded';
|
export const AUTO_UPDATE_DOWNLOADED = 'auto_update_downloaded';
|
||||||
export const AUTO_UPDATE_CONFIRM = 'auto_update_confirm';
|
|
||||||
export const ERROR = 'error';
|
export const ERROR = 'error';
|
||||||
export const UPGRADE = 'upgrade';
|
export const UPGRADE = 'upgrade';
|
||||||
export const WELCOME = 'welcome';
|
export const WELCOME = 'welcome';
|
||||||
|
|
|
@ -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);
|
|
|
@ -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;
|
|
|
@ -33,8 +33,8 @@ class ModalAutoUpdateDownloaded extends React.PureComponent<Props, State> {
|
||||||
type="confirm"
|
type="confirm"
|
||||||
contentLabel={__('Upgrade Downloaded')}
|
contentLabel={__('Upgrade Downloaded')}
|
||||||
title={__('LBRY Leveled Up')}
|
title={__('LBRY Leveled Up')}
|
||||||
confirmButtonLabel={__('Use Now')}
|
confirmButtonLabel={__('Upgrade Now')}
|
||||||
abortButtonLabel={__('Upgrade on Close')}
|
abortButtonLabel={__('Not now')}
|
||||||
confirmButtonDisabled={this.state.disabled}
|
confirmButtonDisabled={this.state.disabled}
|
||||||
onConfirmed={() => {
|
onConfirmed={() => {
|
||||||
this.setState({ disabled: true });
|
this.setState({ disabled: true });
|
||||||
|
@ -42,7 +42,6 @@ class ModalAutoUpdateDownloaded extends React.PureComponent<Props, State> {
|
||||||
}}
|
}}
|
||||||
onAborted={() => {
|
onAborted={() => {
|
||||||
declineAutoUpdate();
|
declineAutoUpdate();
|
||||||
ipcRenderer.send('autoUpdateDeclined');
|
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
|
@ -5,7 +5,6 @@ import ModalError from 'modal/modalError';
|
||||||
import ModalDownloading from 'modal/modalDownloading';
|
import ModalDownloading from 'modal/modalDownloading';
|
||||||
import ModalAutoGenerateThumbnail from 'modal/modalAutoGenerateThumbnail';
|
import ModalAutoGenerateThumbnail from 'modal/modalAutoGenerateThumbnail';
|
||||||
import ModalAutoUpdateDownloaded from 'modal/modalAutoUpdateDownloaded';
|
import ModalAutoUpdateDownloaded from 'modal/modalAutoUpdateDownloaded';
|
||||||
import ModalAutoUpdateConfirm from 'modal/modalAutoUpdateConfirm';
|
|
||||||
import ModalUpgrade from 'modal/modalUpgrade';
|
import ModalUpgrade from 'modal/modalUpgrade';
|
||||||
import ModalWelcome from 'modal/modalWelcome';
|
import ModalWelcome from 'modal/modalWelcome';
|
||||||
import ModalFirstReward from 'modal/modalFirstReward';
|
import ModalFirstReward from 'modal/modalFirstReward';
|
||||||
|
@ -56,8 +55,6 @@ function ModalRouter(props: Props) {
|
||||||
return <ModalAutoGenerateThumbnail {...modalProps} />;
|
return <ModalAutoGenerateThumbnail {...modalProps} />;
|
||||||
case MODALS.AUTO_UPDATE_DOWNLOADED:
|
case MODALS.AUTO_UPDATE_DOWNLOADED:
|
||||||
return <ModalAutoUpdateDownloaded {...modalProps} />;
|
return <ModalAutoUpdateDownloaded {...modalProps} />;
|
||||||
case MODALS.AUTO_UPDATE_CONFIRM:
|
|
||||||
return <ModalAutoUpdateConfirm {...modalProps} />;
|
|
||||||
case MODALS.ERROR:
|
case MODALS.ERROR:
|
||||||
return <ModalError {...modalProps} />;
|
return <ModalError {...modalProps} />;
|
||||||
case MODALS.FILE_TIMEOUT:
|
case MODALS.FILE_TIMEOUT:
|
||||||
|
|
|
@ -133,21 +133,10 @@ export function doDownloadUpgradeRequested() {
|
||||||
// This will probably be reorganized once we get auto-update going on Linux and remove
|
// This will probably be reorganized once we get auto-update going on Linux and remove
|
||||||
// the old logic.
|
// the old logic.
|
||||||
|
|
||||||
return (dispatch, getState) => {
|
return dispatch => {
|
||||||
const state = getState();
|
|
||||||
|
|
||||||
const autoUpdateDeclined = selectAutoUpdateDeclined(state);
|
|
||||||
|
|
||||||
if (['win32', 'darwin'].includes(process.platform)) {
|
if (['win32', 'darwin'].includes(process.platform)) {
|
||||||
// electron-updater behavior
|
// electron-updater behavior
|
||||||
if (autoUpdateDeclined) {
|
dispatch(doOpenModal(MODALS.AUTO_UPDATE_DOWNLOADED));
|
||||||
// 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 {
|
} else {
|
||||||
// Old behavior for Linux
|
// Old behavior for Linux
|
||||||
dispatch(doDownloadUpgrade());
|
dispatch(doDownloadUpgrade());
|
||||||
|
|
Loading…
Add table
Reference in a new issue