fix: error modal handling
This commit is contained in:
parent
9f45b368d4
commit
94fca29323
6 changed files with 16120 additions and 43 deletions
16086
package-lock.json
generated
Normal file
16086
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -129,7 +129,7 @@ export class ExpandableModal extends React.PureComponent<ModalProps, State> {
|
|||
onClick={this.props.onConfirmed}
|
||||
/>
|
||||
<Button
|
||||
button="alt"
|
||||
button="link"
|
||||
label={!this.state.expanded ? this.props.expandButtonLabel : this.props.hideButtonLabel}
|
||||
className="modal__button"
|
||||
onClick={() => {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { connect } from 'react-redux';
|
||||
import * as settings from 'constants/settings';
|
||||
import { selectCurrentModal, selectModalProps, selectModalsAllowed } from 'redux/selectors/app';
|
||||
import {
|
||||
doNotify,
|
||||
selectCostForCurrentPageUri,
|
||||
|
@ -17,8 +16,6 @@ import ModalRouter from './view';
|
|||
const select = state => ({
|
||||
balance: selectBalance(state),
|
||||
showPageCost: selectCostForCurrentPageUri(state),
|
||||
modal: selectCurrentModal(state),
|
||||
modalProps: selectModalProps(state),
|
||||
page: selectCurrentPage(state),
|
||||
isVerificationCandidate: selectUserIsVerificationCandidate(state),
|
||||
isCreditIntroAcknowledged: makeSelectClientSetting(settings.CREDIT_REQUIRED_ACKNOWLEDGED)(state),
|
||||
|
@ -27,7 +24,6 @@ const select = state => ({
|
|||
),
|
||||
isWelcomeAcknowledged: makeSelectClientSetting(settings.NEW_USER_ACKNOWLEDGED)(state),
|
||||
user: selectUser(state),
|
||||
modalsAllowed: selectModalsAllowed(state),
|
||||
notification: selectNotification(state),
|
||||
notificationProps: selectNotificationProps(state),
|
||||
});
|
||||
|
|
|
@ -107,6 +107,11 @@ class ModalRouter extends React.PureComponent {
|
|||
if (!notification) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (notification.error) {
|
||||
return <ModalError {...notification} {...notificationProps} />;
|
||||
}
|
||||
|
||||
switch (notification.id) {
|
||||
case modals.UPGRADE:
|
||||
return <ModalUpgrade {...notificationProps} />;
|
||||
|
|
|
@ -3,7 +3,13 @@ import isDev from 'electron-is-dev';
|
|||
import path from 'path';
|
||||
import * as MODALS from 'constants/modal_types';
|
||||
import { ipcRenderer, remote } from 'electron';
|
||||
import { ACTIONS, Lbry, doBalanceSubscribe, doFetchFileInfosAndPublishedClaims } from 'lbry-redux';
|
||||
import {
|
||||
ACTIONS,
|
||||
Lbry,
|
||||
doBalanceSubscribe,
|
||||
doFetchFileInfosAndPublishedClaims,
|
||||
doNotify,
|
||||
} from 'lbry-redux';
|
||||
import Native from 'native';
|
||||
import { doFetchRewardedContent } from 'redux/actions/content';
|
||||
import { doFetchDaemonSettings } from 'redux/actions/settings';
|
||||
|
@ -83,12 +89,9 @@ export function doDownloadUpgrade() {
|
|||
dispatch({
|
||||
type: ACTIONS.UPGRADE_DOWNLOAD_STARTED,
|
||||
});
|
||||
dispatch({
|
||||
type: ACTIONS.CREATE_NOTIFICATION,
|
||||
data: {
|
||||
modal: MODALS.DOWNLOADING,
|
||||
},
|
||||
});
|
||||
dispatch(doNotify({
|
||||
id: MODALS.DOWNLOADING,
|
||||
}));
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -110,17 +113,15 @@ export function doDownloadUpgradeRequested() {
|
|||
// electron-updater behavior
|
||||
if (autoUpdateDeclined) {
|
||||
// The user declined an update before, so show the "confirm" dialog
|
||||
dispatch({
|
||||
type: ACTIONS.CREATE_NOTIFICATION,
|
||||
data: { modal: MODALS.AUTO_UPDATE_CONFIRM },
|
||||
});
|
||||
dispatch(doNotify({
|
||||
id: 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.CREATE_NOTIFICATION,
|
||||
data: { modal: MODALS.AUTO_UPDATE_DOWNLOADED },
|
||||
});
|
||||
dispatch(doNotify({
|
||||
id: MODALS.AUTO_UPDATE_DOWNLOADED
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
// Old behavior for Linux
|
||||
|
@ -135,10 +136,9 @@ export function doAutoUpdate() {
|
|||
type: ACTIONS.AUTO_UPDATE_DOWNLOADED,
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: ACTIONS.CREATE_NOTIFICATION,
|
||||
data: { modal: MODALS.AUTO_UPDATE_DOWNLOADED },
|
||||
});
|
||||
dispatch(doNotify({
|
||||
id: MODALS.AUTO_UPDATE_DOWNLOADED
|
||||
}));
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -206,12 +206,9 @@ export function doCheckUpgradeAvailable() {
|
|||
!selectCurrentModal(state) &&
|
||||
(!selectIsUpgradeSkipped(state) || remoteVersion !== selectRemoteVersion(state))
|
||||
) {
|
||||
dispatch({
|
||||
type: ACTIONS.CREATE_NOTIFICATION,
|
||||
data: {
|
||||
modal: MODALS.UPGRADE,
|
||||
},
|
||||
});
|
||||
dispatch(doNotify({
|
||||
id: MODALS.UPGRADE
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -256,13 +253,12 @@ export function doCheckDaemonVersion() {
|
|||
|
||||
export function doAlertError(errorList) {
|
||||
return dispatch => {
|
||||
dispatch({
|
||||
type: ACTIONS.CREATE_NOTIFICATION,
|
||||
data: {
|
||||
modal: MODALS.ERROR,
|
||||
modalProps: { error: errorList },
|
||||
},
|
||||
});
|
||||
dispatch(
|
||||
doNotify({
|
||||
id: MODALS.ERROR,
|
||||
error: errorList,
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -41,8 +41,6 @@ export const selectUpgradeFilename = createSelector(
|
|||
}
|
||||
);
|
||||
|
||||
export const selectCurrentModal = createSelector(selectState, state => state.modal);
|
||||
|
||||
export const selectDownloadProgress = createSelector(selectState, state => state.downloadProgress);
|
||||
|
||||
export const selectDownloadComplete = createSelector(
|
||||
|
@ -66,10 +64,6 @@ export const selectAutoUpdateDeclined = createSelector(
|
|||
state => state.autoUpdateDeclined
|
||||
);
|
||||
|
||||
export const selectModalsAllowed = createSelector(selectState, state => state.modalsAllowed);
|
||||
|
||||
export const selectModalProps = createSelector(selectState, state => state.modalProps);
|
||||
|
||||
export const selectDaemonVersionMatched = createSelector(
|
||||
selectState,
|
||||
state => state.daemonVersionMatched
|
||||
|
|
Loading…
Reference in a new issue