mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-09-01 17:55:11 +00:00
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 UPDATE_REMOTE_VERSION = 'UPDATE_REMOTE_VERSION';
|
||||||
export const SKIP_UPGRADE = 'SKIP_UPGRADE';
|
export const SKIP_UPGRADE = 'SKIP_UPGRADE';
|
||||||
export const START_UPGRADE = 'START_UPGRADE';
|
export const START_UPGRADE = 'START_UPGRADE';
|
||||||
|
export const AUTO_UPDATE_DECLINED = 'AUTO_UPDATE_DECLINED';
|
||||||
export const AUTO_UPDATE_DOWNLOADED = 'AUTO_UPDATE_DOWNLOADED';
|
export const AUTO_UPDATE_DOWNLOADED = 'AUTO_UPDATE_DOWNLOADED';
|
||||||
|
|
||||||
// Wallet
|
// Wallet
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { doCloseModal } from "redux/actions/app";
|
import { doCloseModal, doAutoUpdateDeclined } from "redux/actions/app";
|
||||||
import ModalAutoUpdateConfirm from "./view";
|
import ModalAutoUpdateConfirm from "./view";
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
closeModal: () => dispatch(doCloseModal()),
|
closeModal: () => dispatch(doCloseModal()),
|
||||||
|
declineAutoUpdate: () => dispatch(doAutoUpdateDeclined()),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(null, perform)(ModalAutoUpdateConfirm);
|
export default connect(null, perform)(ModalAutoUpdateConfirm);
|
||||||
|
|
|
@ -7,7 +7,7 @@ const { ipcRenderer } = require("electron");
|
||||||
|
|
||||||
class ModalAutoUpdateConfirm extends React.PureComponent {
|
class ModalAutoUpdateConfirm extends React.PureComponent {
|
||||||
render() {
|
render() {
|
||||||
const { closeModal } = this.props;
|
const { closeModal, declineAutoUpdate } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
|
@ -20,6 +20,7 @@ class ModalAutoUpdateConfirm extends React.PureComponent {
|
||||||
ipcRenderer.send("autoUpdateAccepted");
|
ipcRenderer.send("autoUpdateAccepted");
|
||||||
}}
|
}}
|
||||||
onAborted={() => {
|
onAborted={() => {
|
||||||
|
declineAutoUpdate();
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { doCloseModal } from "redux/actions/app";
|
import { doCloseModal, doAutoUpdateDeclined } from "redux/actions/app";
|
||||||
import ModalAutoUpdateDownloaded from "./view";
|
import ModalAutoUpdateDownloaded from "./view";
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
closeModal: () => dispatch(doCloseModal()),
|
closeModal: () => dispatch(doCloseModal()),
|
||||||
|
declineAutoUpdate: () => dispatch(doAutoUpdateDeclined()),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(null, perform)(ModalAutoUpdateDownloaded);
|
export default connect(null, perform)(ModalAutoUpdateDownloaded);
|
||||||
|
|
|
@ -7,7 +7,7 @@ const { ipcRenderer } = require("electron");
|
||||||
|
|
||||||
class ModalAutoUpdateDownloaded extends React.PureComponent {
|
class ModalAutoUpdateDownloaded extends React.PureComponent {
|
||||||
render() {
|
render() {
|
||||||
const { closeModal } = this.props;
|
const { closeModal, declineAutoUpdate } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
|
@ -20,6 +20,7 @@ class ModalAutoUpdateDownloaded extends React.PureComponent {
|
||||||
ipcRenderer.send("autoUpdateAccepted");
|
ipcRenderer.send("autoUpdateAccepted");
|
||||||
}}
|
}}
|
||||||
onAborted={() => {
|
onAborted={() => {
|
||||||
|
declineAutoUpdate();
|
||||||
ipcRenderer.send("autoUpdateDeclined");
|
ipcRenderer.send("autoUpdateDeclined");
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doOpenModal } from 'redux/actions/app';
|
import { doOpenModal } from 'redux/actions/app';
|
||||||
import * as settings from 'constants/settings';
|
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 { selectCurrentPage } from 'redux/selectors/navigation';
|
||||||
import { selectCostForCurrentPageUri } from 'redux/selectors/cost_info';
|
import { selectCostForCurrentPageUri } from 'redux/selectors/cost_info';
|
||||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||||
|
@ -24,6 +24,7 @@ const select = (state, props) => ({
|
||||||
),
|
),
|
||||||
isWelcomeAcknowledged: makeSelectClientSetting(settings.NEW_USER_ACKNOWLEDGED)(state),
|
isWelcomeAcknowledged: makeSelectClientSetting(settings.NEW_USER_ACKNOWLEDGED)(state),
|
||||||
user: selectUser(state),
|
user: selectUser(state),
|
||||||
|
modalsAllowed: selectModalsAllowed(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
|
|
|
@ -97,7 +97,7 @@ class ModalRouter extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { modal, modalProps } = this.props;
|
const { modal, modalsAllowed, modalProps } = this.props;
|
||||||
|
|
||||||
switch (modal) {
|
switch (modal) {
|
||||||
case modals.UPGRADE:
|
case modals.UPGRADE:
|
||||||
|
|
|
@ -18,6 +18,7 @@ import {
|
||||||
selectUpgradeDownloadItem,
|
selectUpgradeDownloadItem,
|
||||||
selectUpgradeDownloadPath,
|
selectUpgradeDownloadPath,
|
||||||
selectUpgradeFilename,
|
selectUpgradeFilename,
|
||||||
|
selectAutoUpdateDeclined,
|
||||||
} from 'redux/selectors/app';
|
} from 'redux/selectors/app';
|
||||||
|
|
||||||
const { autoUpdater } = remote.require('electron-updater');
|
const { autoUpdater } = remote.require('electron-updater');
|
||||||
|
@ -75,12 +76,23 @@ export function doDownloadUpgradeRequested() {
|
||||||
|
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
|
const autoUpdateDeclined = selectAutoUpdateDeclined(state);
|
||||||
|
|
||||||
if (['win32', 'darwin'].includes(process.platform)) { // electron-updater behavior
|
if (['win32', 'darwin'].includes(process.platform)) { // electron-updater behavior
|
||||||
dispatch({
|
if (autoUpdateDeclined) {
|
||||||
type: ACTIONS.OPEN_MODAL,
|
// The user declined an update before, so show the "confirm" dialog
|
||||||
data: { modal: MODALS.AUTO_UPDATE_CONFIRM },
|
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
|
} else { // Old behavior for Linux
|
||||||
doDownloadUpgrade();
|
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() {
|
export function doCancelUpgrade() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
|
|
|
@ -26,6 +26,8 @@ export type AppState = {
|
||||||
hasSignature: boolean,
|
hasSignature: boolean,
|
||||||
badgeNumber: number,
|
badgeNumber: number,
|
||||||
volume: number,
|
volume: number,
|
||||||
|
autoUpdateDeclined: boolean,
|
||||||
|
modalsAllowed: boolean,
|
||||||
downloadProgress: ?number,
|
downloadProgress: ?number,
|
||||||
upgradeDownloading: ?boolean,
|
upgradeDownloading: ?boolean,
|
||||||
upgradeDownloadComplete: ?boolean,
|
upgradeDownloadComplete: ?boolean,
|
||||||
|
@ -47,6 +49,8 @@ const defaultState: AppState = {
|
||||||
badgeNumber: 0,
|
badgeNumber: 0,
|
||||||
volume: Number(sessionStorage.getItem('volume')) || 1,
|
volume: Number(sessionStorage.getItem('volume')) || 1,
|
||||||
autoUpdateDownloaded: false,
|
autoUpdateDownloaded: false,
|
||||||
|
autoUpdateDeclined: false,
|
||||||
|
modalsAllowed: true,
|
||||||
|
|
||||||
downloadProgress: undefined,
|
downloadProgress: undefined,
|
||||||
upgradeDownloading: undefined,
|
upgradeDownloading: undefined,
|
||||||
|
@ -85,6 +89,13 @@ reducers[ACTIONS.AUTO_UPDATE_DOWNLOADED] = state =>
|
||||||
autoUpdateDownloaded: true,
|
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) =>
|
reducers[ACTIONS.UPGRADE_DOWNLOAD_COMPLETED] = (state, action) =>
|
||||||
Object.assign({}, state, {
|
Object.assign({}, state, {
|
||||||
downloadPath: action.data.path,
|
downloadPath: action.data.path,
|
||||||
|
@ -97,6 +108,11 @@ reducers[ACTIONS.UPGRADE_DOWNLOAD_STARTED] = state =>
|
||||||
upgradeDownloading: true,
|
upgradeDownloading: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
reducers[ACTIONS.CHANGE_MODALS_ALLOWED] = (state, action) =>
|
||||||
|
Object.assign({}, state, {
|
||||||
|
modalsAllowed: action.data.modalsAllowed,
|
||||||
|
});
|
||||||
|
|
||||||
reducers[ACTIONS.SKIP_UPGRADE] = state => {
|
reducers[ACTIONS.SKIP_UPGRADE] = state => {
|
||||||
sessionStorage.setItem('upgradeSkipped', 'true');
|
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) =>
|
reducers[ACTIONS.UPDATE_VERSION] = (state, action) =>
|
||||||
Object.assign({}, state, {
|
Object.assign({}, state, {
|
||||||
version: action.data.version,
|
version: action.data.version,
|
||||||
|
@ -122,12 +160,16 @@ reducers[ACTIONS.CHECK_UPGRADE_SUBSCRIBE] = (state, action) =>
|
||||||
checkUpgradeTimer: action.data.checkUpgradeTimer,
|
checkUpgradeTimer: action.data.checkUpgradeTimer,
|
||||||
});
|
});
|
||||||
|
|
||||||
reducers[ACTIONS.OPEN_MODAL] = (state, action) =>
|
reducers[ACTIONS.OPEN_MODAL] = (state, action) => {
|
||||||
Object.assign({}, state, {
|
if (!state.modalsAllowed) {
|
||||||
modal: action.data.modal,
|
return state;
|
||||||
modalProps: action.data.modalProps || {},
|
} else {
|
||||||
});
|
return Object.assign({}, state, {
|
||||||
|
modal: action.data.modal,
|
||||||
|
modalProps: action.data.modalProps || {},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
reducers[ACTIONS.CLOSE_MODAL] = state =>
|
reducers[ACTIONS.CLOSE_MODAL] = state =>
|
||||||
Object.assign({}, state, {
|
Object.assign({}, state, {
|
||||||
modal: undefined,
|
modal: undefined,
|
||||||
|
|
|
@ -58,6 +58,10 @@ export const selectUpgradeDownloadItem = createSelector(selectState, state => st
|
||||||
|
|
||||||
export const selectAutoUpdateDownloaded = createSelector(selectState, state => state.autoUpdateDownloaded);
|
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 selectModalProps = createSelector(selectState, state => state.modalProps);
|
||||||
|
|
||||||
export const selectDaemonVersionMatched = createSelector(
|
export const selectDaemonVersionMatched = createSelector(
|
||||||
|
|
Loading…
Add table
Reference in a new issue