Make new dialogs behave correctly when video is playing
This commit is contained in:
parent
dccb06c13c
commit
863f7dc23b
10 changed files with 89 additions and 16 deletions
|
@ -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_DECLINED = 'AUTO_UPDATE_DECLINED';
|
||||
export const AUTO_UPDATE_DOWNLOADED = 'AUTO_UPDATE_DOWNLOADED';
|
||||
|
||||
// Wallet
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { doCloseModal } from "redux/actions/app";
|
||||
import { doCloseModal, doAutoUpdateDeclined } from "redux/actions/app";
|
||||
import ModalAutoUpdateConfirm from "./view";
|
||||
|
||||
const perform = dispatch => ({
|
||||
closeModal: () => dispatch(doCloseModal()),
|
||||
declineAutoUpdate: () => dispatch(doAutoUpdateDeclined()),
|
||||
});
|
||||
|
||||
export default connect(null, perform)(ModalAutoUpdateConfirm);
|
||||
|
|
|
@ -7,7 +7,7 @@ const { ipcRenderer } = require("electron");
|
|||
|
||||
class ModalAutoUpdateConfirm extends React.PureComponent {
|
||||
render() {
|
||||
const { closeModal } = this.props;
|
||||
const { closeModal, declineAutoUpdate } = this.props;
|
||||
|
||||
return (
|
||||
<Modal
|
||||
|
@ -20,6 +20,7 @@ class ModalAutoUpdateConfirm extends React.PureComponent {
|
|||
ipcRenderer.send("autoUpdateAccepted");
|
||||
}}
|
||||
onAborted={() => {
|
||||
declineAutoUpdate();
|
||||
closeModal();
|
||||
}}
|
||||
>
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { doCloseModal } from "redux/actions/app";
|
||||
import { doCloseModal, doAutoUpdateDeclined } from "redux/actions/app";
|
||||
import ModalAutoUpdateDownloaded from "./view";
|
||||
|
||||
const perform = dispatch => ({
|
||||
closeModal: () => dispatch(doCloseModal()),
|
||||
declineAutoUpdate: () => dispatch(doAutoUpdateDeclined()),
|
||||
});
|
||||
|
||||
export default connect(null, perform)(ModalAutoUpdateDownloaded);
|
||||
|
|
|
@ -7,7 +7,7 @@ const { ipcRenderer } = require("electron");
|
|||
|
||||
class ModalAutoUpdateDownloaded extends React.PureComponent {
|
||||
render() {
|
||||
const { closeModal } = this.props;
|
||||
const { closeModal, declineAutoUpdate } = this.props;
|
||||
|
||||
return (
|
||||
<Modal
|
||||
|
@ -20,6 +20,7 @@ class ModalAutoUpdateDownloaded extends React.PureComponent {
|
|||
ipcRenderer.send("autoUpdateAccepted");
|
||||
}}
|
||||
onAborted={() => {
|
||||
declineAutoUpdate();
|
||||
ipcRenderer.send("autoUpdateDeclined");
|
||||
closeModal();
|
||||
}}
|
||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
|||
import { connect } from 'react-redux';
|
||||
import { doOpenModal } from 'redux/actions/app';
|
||||
import * as settings from 'constants/settings';
|
||||
import { selectCurrentModal, selectModalProps } from 'redux/selectors/app';
|
||||
import { selectCurrentModal, selectModalProps, selectModalsAllowed } from 'redux/selectors/app';
|
||||
import { selectCurrentPage } from 'redux/selectors/navigation';
|
||||
import { selectCostForCurrentPageUri } from 'redux/selectors/cost_info';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
|
@ -24,6 +24,7 @@ const select = (state, props) => ({
|
|||
),
|
||||
isWelcomeAcknowledged: makeSelectClientSetting(settings.NEW_USER_ACKNOWLEDGED)(state),
|
||||
user: selectUser(state),
|
||||
modalsAllowed: selectModalsAllowed(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
|
|
|
@ -97,7 +97,7 @@ class ModalRouter extends React.PureComponent {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { modal, modalProps } = this.props;
|
||||
const { modal, modalsAllowed, modalProps } = this.props;
|
||||
|
||||
switch (modal) {
|
||||
case modals.UPGRADE:
|
||||
|
|
|
@ -18,6 +18,7 @@ import {
|
|||
selectUpgradeDownloadItem,
|
||||
selectUpgradeDownloadPath,
|
||||
selectUpgradeFilename,
|
||||
selectAutoUpdateDeclined,
|
||||
} from 'redux/selectors/app';
|
||||
|
||||
const { autoUpdater } = remote.require('electron-updater');
|
||||
|
@ -75,12 +76,23 @@ export function doDownloadUpgradeRequested() {
|
|||
|
||||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const autoUpdateDeclined = selectAutoUpdateDeclined(state);
|
||||
|
||||
if (['win32', 'darwin'].includes(process.platform)) { // electron-updater behavior
|
||||
dispatch({
|
||||
type: ACTIONS.OPEN_MODAL,
|
||||
data: { modal: MODALS.AUTO_UPDATE_CONFIRM },
|
||||
});
|
||||
if (autoUpdateDeclined) {
|
||||
// The user declined an update before, so show the "confirm" dialog
|
||||
dispatch({
|
||||
type: ACTIONS.OPEN_MODAL,
|
||||
data: { modal: 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({
|
||||
type: ACTIONS.OPEN_MODAL,
|
||||
data: { modal: MODALS.AUTO_UPDATE_DOWNLOADED },
|
||||
});
|
||||
}
|
||||
} else { // Old behavior for Linux
|
||||
doDownloadUpgrade();
|
||||
}
|
||||
|
@ -140,6 +152,15 @@ export function doAutoUpdate() {
|
|||
};
|
||||
}
|
||||
|
||||
export function doAutoUpdateDeclined() {
|
||||
return function(dispatch, getState) {
|
||||
const state = getState();
|
||||
dispatch({
|
||||
type: ACTIONS.AUTO_UPDATE_DECLINED,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function doCancelUpgrade() {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
|
|
|
@ -26,6 +26,8 @@ export type AppState = {
|
|||
hasSignature: boolean,
|
||||
badgeNumber: number,
|
||||
volume: number,
|
||||
autoUpdateDeclined: boolean,
|
||||
modalsAllowed: boolean,
|
||||
downloadProgress: ?number,
|
||||
upgradeDownloading: ?boolean,
|
||||
upgradeDownloadComplete: ?boolean,
|
||||
|
@ -47,6 +49,8 @@ const defaultState: AppState = {
|
|||
badgeNumber: 0,
|
||||
volume: Number(sessionStorage.getItem('volume')) || 1,
|
||||
autoUpdateDownloaded: false,
|
||||
autoUpdateDeclined: false,
|
||||
modalsAllowed: true,
|
||||
|
||||
downloadProgress: undefined,
|
||||
upgradeDownloading: undefined,
|
||||
|
@ -85,6 +89,13 @@ reducers[ACTIONS.AUTO_UPDATE_DOWNLOADED] = state =>
|
|||
autoUpdateDownloaded: true,
|
||||
});
|
||||
|
||||
reducers[ACTIONS.AUTO_UPDATE_DECLINED] = state => {
|
||||
console.log('in AUTO_UPDATE_DECLINED reducer')
|
||||
return Object.assign({}, state, {
|
||||
autoUpdateDeclined: true,
|
||||
});
|
||||
}
|
||||
|
||||
reducers[ACTIONS.UPGRADE_DOWNLOAD_COMPLETED] = (state, action) =>
|
||||
Object.assign({}, state, {
|
||||
downloadPath: action.data.path,
|
||||
|
@ -97,6 +108,11 @@ reducers[ACTIONS.UPGRADE_DOWNLOAD_STARTED] = state =>
|
|||
upgradeDownloading: true,
|
||||
});
|
||||
|
||||
reducers[ACTIONS.CHANGE_MODALS_ALLOWED] = (state, action) =>
|
||||
Object.assign({}, state, {
|
||||
modalsAllowed: action.data.modalsAllowed,
|
||||
});
|
||||
|
||||
reducers[ACTIONS.SKIP_UPGRADE] = state => {
|
||||
sessionStorage.setItem('upgradeSkipped', 'true');
|
||||
|
||||
|
@ -106,6 +122,28 @@ reducers[ACTIONS.SKIP_UPGRADE] = state => {
|
|||
});
|
||||
};
|
||||
|
||||
reducers[ACTIONS.MEDIA_PLAY] = state => {
|
||||
return Object.assign({}, state, {
|
||||
modalsAllowed: false,
|
||||
});
|
||||
};
|
||||
|
||||
reducers[ACTIONS.MEDIA_PAUSE] = state => {
|
||||
return Object.assign({}, state, {
|
||||
modalsAllowed: true,
|
||||
});
|
||||
};
|
||||
|
||||
reducers[ACTIONS.SET_PLAYING_URI] = (state, action) => {
|
||||
if (action.data.uri === null) {
|
||||
return Object.assign({}, state, {
|
||||
modalsAllowed: true,
|
||||
});
|
||||
} else {
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
reducers[ACTIONS.UPDATE_VERSION] = (state, action) =>
|
||||
Object.assign({}, state, {
|
||||
version: action.data.version,
|
||||
|
@ -122,12 +160,16 @@ reducers[ACTIONS.CHECK_UPGRADE_SUBSCRIBE] = (state, action) =>
|
|||
checkUpgradeTimer: action.data.checkUpgradeTimer,
|
||||
});
|
||||
|
||||
reducers[ACTIONS.OPEN_MODAL] = (state, action) =>
|
||||
Object.assign({}, state, {
|
||||
modal: action.data.modal,
|
||||
modalProps: action.data.modalProps || {},
|
||||
});
|
||||
|
||||
reducers[ACTIONS.OPEN_MODAL] = (state, action) => {
|
||||
if (!state.modalsAllowed) {
|
||||
return state;
|
||||
} else {
|
||||
return Object.assign({}, state, {
|
||||
modal: action.data.modal,
|
||||
modalProps: action.data.modalProps || {},
|
||||
});
|
||||
}
|
||||
};
|
||||
reducers[ACTIONS.CLOSE_MODAL] = state =>
|
||||
Object.assign({}, state, {
|
||||
modal: undefined,
|
||||
|
|
|
@ -58,6 +58,10 @@ export const selectUpgradeDownloadItem = createSelector(selectState, state => st
|
|||
|
||||
export const selectAutoUpdateDownloaded = createSelector(selectState, state => state.autoUpdateDownloaded);
|
||||
|
||||
export const selectAutoUpdateDeclined = createSelector(selectState, state => state.autoUpdateDeclined);
|
||||
|
||||
export const selectModalsAllowed = createSelector(selectState, state => state.modalsAllowed);
|
||||
|
||||
export const selectModalProps = createSelector(selectState, state => state.modalProps);
|
||||
|
||||
export const selectDaemonVersionMatched = createSelector(
|
||||
|
|
Loading…
Reference in a new issue