Add alert before close after update is declined on Windows
This commit is contained in:
parent
bc15d24d66
commit
b08d96da1e
8 changed files with 68 additions and 5 deletions
|
@ -48,6 +48,20 @@ let daemonSubprocess;
|
|||
// if it dies when we didn't ask it to shut down, we want to alert the user.
|
||||
let daemonStopRequested = false;
|
||||
|
||||
// This keeps track of whether a new file has been downloaded. We mostly
|
||||
// handle auto-update stuff in the render process, but need to know this
|
||||
// in order to display the extra confirmation dialog we show on close
|
||||
// on Windows.
|
||||
let updateDownloaded;
|
||||
if (process.platform === 'win32') {
|
||||
updateDownloaded = false;
|
||||
}
|
||||
|
||||
// This is used to keep track of whether we are showing he special dialog
|
||||
// that we show on Windows after you decline an upgrade and close the app later.
|
||||
let showingUpdateCloseAlert = false;
|
||||
|
||||
|
||||
// When a quit is attempted, we cancel the quit, do some preparations, then
|
||||
// this is set to true and app.quit() is called again to quit for real.
|
||||
let readyToQuit = false;
|
||||
|
@ -406,6 +420,10 @@ if (isDevelopment) {
|
|||
});
|
||||
}
|
||||
|
||||
autoUpdater.on('update-downloaded', () => {
|
||||
updateDownloaded = true;
|
||||
});
|
||||
|
||||
app.setAsDefaultProtocolClient('lbry');
|
||||
|
||||
app.on('ready', () => {
|
||||
|
@ -431,7 +449,12 @@ app.on('window-all-closed', () => {
|
|||
});
|
||||
|
||||
app.on('before-quit', event => {
|
||||
if (!readyToQuit) {
|
||||
if (process.platform === 'darwin' && updateDownloaded && !showingUpdateCloseAlert) {
|
||||
// We haven't shown the special dialog that we show on Windows
|
||||
// if the user declines an update and then quits later
|
||||
rendererWindow.webContents.send('quitRequested');
|
||||
showingUpdateCloseAlert = true;
|
||||
} else if (!readyToQuit) {
|
||||
// We need to shutdown the daemon before we're ready to actually quit. This
|
||||
// event will be triggered re-entrantly once preparation is done.
|
||||
event.preventDefault();
|
||||
|
|
|
@ -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 UPDATE_CLOSE_ALERT = "updateCloseAlert";
|
||||
export const ERROR = 'error';
|
||||
export const INSUFFICIENT_CREDITS = 'insufficient_credits';
|
||||
export const UPGRADE = 'upgrade';
|
||||
|
|
|
@ -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, doAutoUpdate } from 'redux/actions/app';
|
||||
import { doConditionalAuthNavigate, doOpenModal, 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';
|
||||
|
@ -62,7 +62,7 @@ ipcRenderer.on('window-is-focused', () => {
|
|||
dock.setBadge('');
|
||||
});
|
||||
|
||||
((history, ...args) => {
|
||||
(function(history, ...args) {
|
||||
const { replaceState } = history;
|
||||
const newHistory = history;
|
||||
newHistory.replaceState = (_, __, path) => {
|
||||
|
|
|
@ -2,6 +2,7 @@ import React from "react";
|
|||
import { connect } from "react-redux";
|
||||
import { doCloseModal } from "redux/actions/app";
|
||||
import ModalAutoUpdateDownloaded from "./view";
|
||||
import { doCloseModal } from "redux/actions/app";
|
||||
|
||||
const perform = dispatch => ({
|
||||
closeModal: () => dispatch(doCloseModal()),
|
||||
|
|
|
@ -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 ModalUpdateCloseAlert from "modal/modalUpdateCloseAlert";
|
||||
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.UPDATE_CLOSE_ALERT:
|
||||
return <ModalUpdateCloseAlert {...modalProps} />;
|
||||
case modals.ERROR:
|
||||
return <ModalError {...modalProps} />;
|
||||
case modals.FILE_TIMEOUT:
|
||||
|
|
12
src/renderer/modal/modalUpdateCloseAlert/index.js
Normal file
12
src/renderer/modal/modalUpdateCloseAlert/index.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { doQuit } from 'redux/actions/app';
|
||||
import ModalUpdateCloseAlert from './view';
|
||||
|
||||
const select = state => ({});
|
||||
|
||||
const perform = dispatch => ({
|
||||
quit: () => dispatch(doSkipUpgrade()),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(ModalUpdateCloseAlert);
|
23
src/renderer/modal/modalUpdateCloseAlert/view.jsx
Normal file
23
src/renderer/modal/modalUpdateCloseAlert/view.jsx
Normal file
|
@ -0,0 +1,23 @@
|
|||
import React from 'react';
|
||||
import { Modal } from 'modal/modal';
|
||||
import Link from 'component/link';
|
||||
|
||||
class ModalUpdateCloseAlert extends React.PureComponent {
|
||||
render() {
|
||||
const { quit } = this.props;
|
||||
|
||||
return (
|
||||
<Modal
|
||||
isOpen
|
||||
type="alert"
|
||||
confirmButtonLabel={__('Close Now')}
|
||||
onConfirmed={quit}
|
||||
>
|
||||
<h3 className="text-center">{__('LBRY Will Upgrade')}</h3>
|
||||
<p>{__('Please select yes to the upgrade prompt shown after the app closes.')}</p>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default ModalUpdateCloseAlert;
|
|
@ -110,8 +110,8 @@ export function doAutoUpdate() {
|
|||
return function(dispatch, getState) {
|
||||
const state = getState();
|
||||
dispatch({
|
||||
type: types.OPEN_MODAL,
|
||||
data: { modal: modals.AUTO_UPDATE_DOWNLOADED },
|
||||
type: ACTIONS.OPEN_MODAL,
|
||||
data: { modal: MODALS.AUTO_UPDATE_DOWNLOADED },
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue