Revert "move modals to app and use doToast/doError"

This reverts commit 24100fac06.
This commit is contained in:
Sean Yesmunt 2018-10-29 13:25:22 -04:00
parent 24100fac06
commit 78c27b4601
72 changed files with 267 additions and 313 deletions

View file

@ -134,7 +134,7 @@
"yarn": "^1.3" "yarn": "^1.3"
}, },
"lbrySettings": { "lbrySettings": {
"lbrynetDaemonVersion": "0.30.1rc1", "lbrynetDaemonVersion": "0.30.0",
"lbrynetDaemonUrlTemplate": "https://github.com/lbryio/lbry/releases/download/vDAEMONVER/lbrynet-OSNAME.zip", "lbrynetDaemonUrlTemplate": "https://github.com/lbryio/lbry/releases/download/vDAEMONVER/lbrynet-OSNAME.zip",
"lbrynetDaemonDir": "static/daemon", "lbrynetDaemonDir": "static/daemon",
"lbrynetDaemonFileName": "lbrynet" "lbrynetDaemonFileName": "lbrynet"

View file

@ -1,12 +1,12 @@
// @flow // @flow
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doToast } from 'lbry-redux'; import { doNotify } from 'lbry-redux';
import Address from './view'; import Address from './view';
export default connect( export default connect(
null, null,
{ {
doToast, doNotify,
} }
)(Address); )(Address);

View file

@ -11,7 +11,8 @@ https://github.com/lbryio/lbry-desktop/issues/1945
*/ */
type Props = { type Props = {
address: string, address: string,
doToast: ({ message: string }) => void, noSnackbar: boolean,
doNotify: ({ message: string, displayType: Array<string> }) => void,
}; };
export default class Address extends React.PureComponent<Props> { export default class Address extends React.PureComponent<Props> {
@ -24,7 +25,7 @@ export default class Address extends React.PureComponent<Props> {
input: ?HTMLInputElement; input: ?HTMLInputElement;
render() { render() {
const { address, doToast } = this.props; const { address, doNotify, noSnackbar } = this.props;
return ( return (
<FormRow verticallyCentered padded stretch> <FormRow verticallyCentered padded stretch>
@ -47,9 +48,12 @@ export default class Address extends React.PureComponent<Props> {
icon={icons.CLIPBOARD} icon={icons.CLIPBOARD}
onClick={() => { onClick={() => {
clipboard.writeText(address); clipboard.writeText(address);
doToast({ if (!noSnackbar) {
doNotify({
message: __('Address copied'), message: __('Address copied'),
displayType: ['snackbar'],
}); });
}
}} }}
/> />
</FormRow> </FormRow>

View file

@ -1,7 +1,8 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectPageTitle, selectHistoryIndex, selectActiveHistoryEntry, doError } from 'lbry-redux'; import { selectPageTitle, selectHistoryIndex, selectActiveHistoryEntry } from 'lbry-redux';
import { doRecordScroll } from 'redux/actions/navigation'; import { doRecordScroll } from 'redux/actions/navigation';
import { selectUser } from 'lbryinc'; import { selectUser } from 'lbryinc';
import { doAlertError } from 'redux/actions/app';
import { selectThemePath } from 'redux/selectors/settings'; import { selectThemePath } from 'redux/selectors/settings';
import App from './view'; import App from './view';
@ -14,7 +15,7 @@ const select = state => ({
}); });
const perform = dispatch => ({ const perform = dispatch => ({
alertError: errorList => dispatch(doError(errorList)), alertError: errorList => dispatch(doAlertError(errorList)),
recordScroll: scrollPosition => dispatch(doRecordScroll(scrollPosition)), recordScroll: scrollPosition => dispatch(doRecordScroll(scrollPosition)),
}); });

View file

@ -1,10 +1,10 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doToast } from 'lbry-redux'; import { doNotify } from 'lbry-redux';
import CopyableText from './view'; import CopyableText from './view';
export default connect( export default connect(
null, null,
{ {
doToast, doNotify,
} }
)(CopyableText); )(CopyableText);

View file

@ -4,10 +4,15 @@ import { clipboard } from 'electron';
import { FormRow } from 'component/common/form'; import { FormRow } from 'component/common/form';
import Button from 'component/button'; import Button from 'component/button';
import * as icons from 'constants/icons'; import * as icons from 'constants/icons';
/*
noSnackbar added due to issue 1945
https://github.com/lbryio/lbry-desktop/issues/1945
"Snackbars and modals can't be displayed at the same time"
*/
type Props = { type Props = {
copyable: string, copyable: string,
doToast: ({ message: string }) => void, noSnackbar: boolean,
doNotify: ({ message: string, displayType: Array<string> }) => void,
}; };
export default class CopyableText extends React.PureComponent<Props> { export default class CopyableText extends React.PureComponent<Props> {
@ -20,7 +25,7 @@ export default class CopyableText extends React.PureComponent<Props> {
input: ?HTMLInputElement; input: ?HTMLInputElement;
render() { render() {
const { copyable, doToast, noSnackbar } = this.props; const { copyable, doNotify, noSnackbar } = this.props;
return ( return (
<FormRow verticallyCentered padded stretch> <FormRow verticallyCentered padded stretch>
@ -44,9 +49,12 @@ export default class CopyableText extends React.PureComponent<Props> {
icon={icons.CLIPBOARD} icon={icons.CLIPBOARD}
onClick={() => { onClick={() => {
clipboard.writeText(copyable); clipboard.writeText(copyable);
doToast({ if (!noSnackbar) {
doNotify({
message: __('Text copied'), message: __('Text copied'),
displayType: ['snackbar'],
}); });
}
}} }}
/> />
</FormRow> </FormRow>

View file

@ -1,12 +1,12 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doOpenModal } from 'redux/actions/app'; import { doNotify } from 'lbry-redux';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import ExternalLink from './view'; import ExternalLink from './view';
const select = () => ({}); const select = () => ({});
const perform = dispatch => ({ const perform = dispatch => ({
navigate: (path, params) => dispatch(doNavigate(path, params)), navigate: (path, params) => dispatch(doNavigate(path, params)),
openModal: (modal, props) => dispatch(doOpenModal(modal, props)), openModal: (modal, props) => dispatch(doNotify(modal, props)),
}); });
export default connect(select, perform)(ExternalLink); export default connect(select, perform)(ExternalLink);

View file

@ -1,8 +1,7 @@
// @flow // @flow
import * as MODALS from 'constants/modal_types';
import * as ICONS from 'constants/icons';
import * as React from 'react'; import * as React from 'react';
import { isURIValid } from 'lbry-redux'; import { MODALS, isURIValid } from 'lbry-redux';
import * as icons from 'constants/icons';
import Button from 'component/button'; import Button from 'component/button';
type Props = { type Props = {
@ -10,7 +9,7 @@ type Props = {
title?: string, title?: string,
children: React.Node, children: React.Node,
navigate: (string, ?{}) => void, navigate: (string, ?{}) => void,
openModal: (id: string, { uri: string }) => void, openModal: ({ id: string }, { uri: string }) => void,
}; };
class ExternalLink extends React.PureComponent<Props> { class ExternalLink extends React.PureComponent<Props> {
@ -34,11 +33,11 @@ class ExternalLink extends React.PureComponent<Props> {
element = ( element = (
<Button <Button
button="link" button="link"
iconRight={ICONS.EXTERNAL_LINK} iconRight={icons.EXTERNAL_LINK}
title={title || href} title={title || href}
label={children} label={children}
className="btn--external-link" className="btn--external-link"
onClick={() => openModal(MODALS.CONFIRM_EXTERNAL_LINK, { uri: href })} onClick={() => openModal({ id: MODALS.CONFIRM_EXTERNAL_LINK }, { uri: href })}
/> />
); );
} }

View file

@ -3,7 +3,7 @@ import {
makeSelectCostInfoForUri, makeSelectCostInfoForUri,
makeSelectFileInfoForUri, makeSelectFileInfoForUri,
makeSelectClaimIsMine, makeSelectClaimIsMine,
doOpenModal, doNotify,
} from 'lbry-redux'; } from 'lbry-redux';
import FileActions from './view'; import FileActions from './view';
@ -15,7 +15,7 @@ const select = (state, props) => ({
}); });
const perform = dispatch => ({ const perform = dispatch => ({
openModal: (modal, props) => dispatch(doOpenModal(modal, props)), openModal: (modal, props) => dispatch(doNotify(modal, props)),
}); });
export default connect(select, perform)(FileActions); export default connect(select, perform)(FileActions);

View file

@ -1,8 +1,8 @@
// @flow // @flow
import * as MODALS from 'constants/modal_types';
import * as ICONS from 'constants/icons';
import * as React from 'react'; import * as React from 'react';
import Button from 'component/button'; import Button from 'component/button';
import { MODALS } from 'lbry-redux';
import * as icons from 'constants/icons';
import Tooltip from 'component/common/tooltip'; import Tooltip from 'component/common/tooltip';
type FileInfo = { type FileInfo = {
@ -12,7 +12,7 @@ type FileInfo = {
type Props = { type Props = {
uri: string, uri: string,
claimId: string, claimId: string,
openModal: (id: string, { uri: string }) => void, openModal: ({ id: string }, { uri: string }) => void,
claimIsMine: boolean, claimIsMine: boolean,
fileInfo: FileInfo, fileInfo: FileInfo,
}; };
@ -28,9 +28,9 @@ class FileActions extends React.PureComponent<Props> {
<Tooltip onComponent body={__('Delete this file')}> <Tooltip onComponent body={__('Delete this file')}>
<Button <Button
button="alt" button="alt"
icon={ICONS.TRASH} icon={icons.TRASH}
description={__('Delete')} description={__('Delete')}
onClick={() => openModal(MODALS.CONFIRM_FILE_REMOVE, { uri })} onClick={() => openModal({ id: MODALS.CONFIRM_FILE_REMOVE }, { uri })}
/> />
</Tooltip> </Tooltip>
)} )}
@ -38,7 +38,7 @@ class FileActions extends React.PureComponent<Props> {
<Tooltip onComponent body={__('Report content')}> <Tooltip onComponent body={__('Report content')}>
<Button <Button
button="alt" button="alt"
icon={ICONS.REPORT} icon={icons.REPORT}
href={`https://lbry.io/dmca?claim_id=${claimId}`} href={`https://lbry.io/dmca?claim_id=${claimId}`}
/> />
</Tooltip> </Tooltip>

View file

@ -1,10 +1,9 @@
import * as MODALS from 'constants/modal_types';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doOpenModal } from 'lbry-redux'; import { MODALS, doNotify } from 'lbry-redux';
import RewardTile from './view'; import RewardTile from './view';
const perform = dispatch => ({ const perform = dispatch => ({
openRewardCodeModal: () => dispatch(doOpenModal(MODALS.REWARD_GENERATED_CODE)), openRewardCodeModal: () => dispatch(doNotify({ id: MODALS.REWARD_GENERATED_CODE })),
}); });
export default connect( export default connect(

View file

@ -1,6 +1,5 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectCurrentPage, selectCurrentParams } from 'lbry-redux'; import { selectCurrentPage, selectCurrentParams, doNotify } from 'lbry-redux';
import { doOpenModal } from 'redux/actions/app';
import Router from './view'; import Router from './view';
const select = state => ({ const select = state => ({
@ -8,4 +7,4 @@ const select = state => ({
currentPage: selectCurrentPage(state), currentPage: selectCurrentPage(state),
}); });
export default connect(select, { doOpenModal })(Router); export default connect(select, { doNotify })(Router);

View file

@ -23,8 +23,9 @@ import UserHistoryPage from 'page/userHistory';
const route = (props, page, routesMap) => { const route = (props, page, routesMap) => {
const component = routesMap[page]; const component = routesMap[page];
if (!component) { if (!component) {
props.doToast({ props.doNotify({
message: __('Invalid page requested'), message: __('Invalid page requested'),
displayType: ['snackbar'],
}); });
} }
return component || routesMap.discover; return component || routesMap.discover;

View file

@ -1,9 +1,9 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doOpenModal } from 'redux/actions/app'; import { doNotify } from 'lbry-redux';
import SelectThumbnail from './view'; import SelectThumbnail from './view';
const perform = dispatch => ({ const perform = dispatch => ({
openModal: (modal, props) => dispatch(doOpenModal(modal, props)), openModal: (modal, props) => dispatch(doNotify(modal, props)),
}); });
export default connect( export default connect(

View file

@ -1,6 +1,5 @@
// @flow // @flow
import * as MODALS from 'constants/modal_types'; import { THUMBNAIL_STATUSES, MODALS } from 'lbry-redux';
import { THUMBNAIL_STATUSES } from 'lbry-redux';
import * as React from 'react'; import * as React from 'react';
import { FormField } from 'component/common/form'; import { FormField } from 'component/common/form';
import FileSelector from 'component/common/file-selector'; import FileSelector from 'component/common/file-selector';
@ -119,7 +118,7 @@ class SelectThumbnail extends React.PureComponent<Props, State> {
currentPath={thumbnailPath} currentPath={thumbnailPath}
fileLabel={__('Choose Thumbnail')} fileLabel={__('Choose Thumbnail')}
filters={filters} filters={filters}
onFileChosen={path => openModal(MODALS.CONFIRM_THUMBNAIL_UPLOAD, { path })} onFileChosen={path => openModal({ id: MODALS.CONFIRM_THUMBNAIL_UPLOAD }, { path })}
/> />
)} )}
{status === THUMBNAIL_STATUSES.COMPLETE && ( {status === THUMBNAIL_STATUSES.COMPLETE && (

View file

@ -1,13 +1,13 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectToast, doDismissToast } from 'lbry-redux'; import { selectSnack, doHideNotification } from 'lbry-redux';
import SnackBar from './view'; import SnackBar from './view';
const perform = dispatch => ({ const perform = dispatch => ({
removeSnack: () => dispatch(doDismissToast()), removeSnack: () => dispatch(doHideNotification()),
}); });
const select = state => ({ const select = state => ({
snack: selectToast(state), snack: selectSnack(state),
}); });
export default connect(select, perform)(SnackBar); export default connect(select, perform)(SnackBar);

View file

@ -1,7 +1,6 @@
// @flow // @flow
import React from 'react'; import React from 'react';
import Button from 'component/button'; import Button from 'component/button';
import classnames from 'classnames';
type Props = { type Props = {
removeSnack: any => void, removeSnack: any => void,
@ -28,7 +27,7 @@ class SnackBar extends React.PureComponent<Props> {
return null; return null;
} }
const { message, linkText, linkTarget, isError } = snack; const { message, linkText, linkTarget } = snack;
if (this.hideTimeout === null) { if (this.hideTimeout === null) {
this.hideTimeout = setTimeout(() => { this.hideTimeout = setTimeout(() => {
@ -38,9 +37,7 @@ class SnackBar extends React.PureComponent<Props> {
} }
return ( return (
<div className={classnames("snack-bar", { <div className="snack-bar">
"snack-bar--error": isError
})}>
<div className="snack-bar__message"> <div className="snack-bar__message">
<div>&#9432;</div> <div>&#9432;</div>
<div>{message}</div> <div>{message}</div>

View file

@ -46,7 +46,7 @@ class SocialShare extends React.PureComponent<Props> {
{speechShareable && ( {speechShareable && (
<div className="card__content"> <div className="card__content">
<label className="card__subtitle">{__('Web link')}</label> <label className="card__subtitle">{__('Web link')}</label>
<CopyableText copyable={speechURL} /> <CopyableText copyable={speechURL} noSnackbar />
<div className="card__actions card__actions--center"> <div className="card__actions card__actions--center">
<ToolTip onComponent body={__('Facebook')}> <ToolTip onComponent body={__('Facebook')}>
<Button <Button

View file

@ -1,10 +1,11 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectDaemonVersionMatched, selectModal } from 'redux/selectors/app'; import { selectDaemonVersionMatched } from 'redux/selectors/app';
import { selectNotification } from 'lbry-redux';
import { doCheckDaemonVersion, doNotifyUnlockWallet } from 'redux/actions/app'; import { doCheckDaemonVersion, doNotifyUnlockWallet } from 'redux/actions/app';
import SplashScreen from './view'; import SplashScreen from './view';
const select = state => ({ const select = state => ({
modal: selectModal(state), notification: selectNotification(state),
daemonVersionMatched: selectDaemonVersionMatched(state), daemonVersionMatched: selectDaemonVersionMatched(state),
}); });

View file

@ -1,7 +1,6 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import * as MODALS from 'constants/modal_types'; import { Lbry, MODALS } from 'lbry-redux';
import { Lbry } from 'lbry-redux';
import ModalWalletUnlock from 'modal/modalWalletUnlock'; import ModalWalletUnlock from 'modal/modalWalletUnlock';
import ModalIncompatibleDaemon from 'modal/modalIncompatibleDaemon'; import ModalIncompatibleDaemon from 'modal/modalIncompatibleDaemon';
import ModalUpgrade from 'modal/modalUpgrade'; import ModalUpgrade from 'modal/modalUpgrade';
@ -14,7 +13,7 @@ type Props = {
daemonVersionMatched: boolean, daemonVersionMatched: boolean,
onReadyToLaunch: () => void, onReadyToLaunch: () => void,
authenticate: () => void, authenticate: () => void,
modal: ?{ notification: ?{
id: string, id: string,
}, },
}; };
@ -126,11 +125,12 @@ export class SplashScreen extends React.PureComponent<Props, State> {
hasRecordedUser: boolean; hasRecordedUser: boolean;
render() { render() {
const { modal } = this.props; const { notification } = this.props;
const { message, details, isRunning } = this.state; const { message, details, isRunning } = this.state;
const modalId = modal && modal.id; const notificationId = notification && notification.id;
// {notificationId === MODALS.WALLET_UNLOCK && <ModalWalletUnlock />}
return ( return (
<React.Fragment> <React.Fragment>
<LoadScreen message={message} details={details} /> <LoadScreen message={message} details={details} />
@ -139,10 +139,10 @@ export class SplashScreen extends React.PureComponent<Props, State> {
in the modals won't work. */} in the modals won't work. */}
{isRunning && ( {isRunning && (
<React.Fragment> <React.Fragment>
{modalId === MODALS.WALLET_UNLOCK && <ModalWalletUnlock />} {notificationId === MODALS.WALLET_UNLOCK && <ModalWalletUnlock />}
{modalId === MODALS.INCOMPATIBLE_DAEMON && <ModalIncompatibleDaemon />} {notificationId === MODALS.INCOMPATIBLE_DAEMON && <ModalIncompatibleDaemon />}
{modalId === MODALS.UPGRADE && <ModalUpgrade />} {notificationId === MODALS.UPGRADE && <ModalUpgrade />}
{modalId === MODALS.DOWNLOADING && <ModalDownloading />} {notificationId === MODALS.DOWNLOADING && <ModalDownloading />}
</React.Fragment> </React.Fragment>
)} )}
</React.Fragment> </React.Fragment>

View file

@ -1,6 +1,6 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doChannelSubscribe, doChannelUnsubscribe } from 'redux/actions/subscriptions'; import { doChannelSubscribe, doChannelUnsubscribe } from 'redux/actions/subscriptions';
import { doOpenModal } from 'redux/actions/app'; import { doNotify } from 'lbry-redux';
import { selectSubscriptions, makeSelectIsSubscribed } from 'redux/selectors/subscriptions'; import { selectSubscriptions, makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
import SubscribeButton from './view'; import SubscribeButton from './view';
@ -14,6 +14,6 @@ export default connect(
{ {
doChannelSubscribe, doChannelSubscribe,
doChannelUnsubscribe, doChannelUnsubscribe,
doOpenModal, doNotify,
} }
)(SubscribeButton); )(SubscribeButton);

View file

@ -1,7 +1,7 @@
// @flow // @flow
import * as MODALS from 'constants/modal_types';
import * as ICONS from 'constants/icons';
import React from 'react'; import React from 'react';
import { MODALS } from 'lbry-redux';
import * as icons from 'constants/icons';
import Button from 'component/button'; import Button from 'component/button';
type SubscribtionArgs = { type SubscribtionArgs = {
@ -16,7 +16,7 @@ type Props = {
subscriptions: Array<string>, subscriptions: Array<string>,
doChannelSubscribe: ({ channelName: string, uri: string }) => void, doChannelSubscribe: ({ channelName: string, uri: string }) => void,
doChannelUnsubscribe: SubscribtionArgs => void, doChannelUnsubscribe: SubscribtionArgs => void,
doOpenModal: ({ id: string }) => void, doNotify: ({ id: string }) => void,
}; };
export default (props: Props) => { export default (props: Props) => {
@ -25,7 +25,7 @@ export default (props: Props) => {
uri, uri,
doChannelSubscribe, doChannelSubscribe,
doChannelUnsubscribe, doChannelUnsubscribe,
doOpenModal, doNotify,
subscriptions, subscriptions,
isSubscribed, isSubscribed,
} = props; } = props;
@ -36,14 +36,14 @@ export default (props: Props) => {
return channelName && uri ? ( return channelName && uri ? (
<Button <Button
iconColor="red" iconColor="red"
icon={isSubscribed ? undefined : ICONS.HEART} icon={isSubscribed ? undefined : icons.HEART}
button="alt" button="alt"
label={subscriptionLabel} label={subscriptionLabel}
onClick={e => { onClick={e => {
e.stopPropagation(); e.stopPropagation();
if (!subscriptions.length) { if (!subscriptions.length) {
doOpenModal(MODALS.FIRST_SUBSCRIPTION); doNotify({ id: MODALS.FIRST_SUBSCRIPTION });
} }
subscriptionHandler({ subscriptionHandler({
channelName, channelName,

View file

@ -1,9 +1,9 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectClaimedRewardsByTransactionId } from 'lbryinc'; import { selectClaimedRewardsByTransactionId } from 'lbryinc';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import { doOpenModal } from 'redux/actions/app';
import { import {
selectAllMyClaimsByOutpoint, selectAllMyClaimsByOutpoint,
doNotify,
selectTransactionListFilter, selectTransactionListFilter,
doSetTransactionListFilter, doSetTransactionListFilter,
} from 'lbry-redux'; } from 'lbry-redux';
@ -17,7 +17,7 @@ const select = state => ({
const perform = dispatch => ({ const perform = dispatch => ({
navigate: (path, params) => dispatch(doNavigate(path, params)), navigate: (path, params) => dispatch(doNavigate(path, params)),
openModal: (modal, props) => dispatch(doOpenModal(modal, props)), openModal: (modal, props) => dispatch(doNotify(modal, props)),
setTransactionFilter: filterSetting => dispatch(doSetTransactionListFilter(filterSetting)), setTransactionFilter: filterSetting => dispatch(doSetTransactionListFilter(filterSetting)),
}); });

View file

@ -1,11 +1,10 @@
// @flow // @flow
import * as ICONS from 'constants/icons';
import * as MODALS from 'constants/modal_types';
import * as React from 'react'; import * as React from 'react';
import { FormField } from 'component/common/form'; import { FormField } from 'component/common/form';
import Button from 'component/button'; import Button from 'component/button';
import FileExporter from 'component/common/file-exporter'; import FileExporter from 'component/common/file-exporter';
import { TRANSACTIONS } from 'lbry-redux'; import * as icons from 'constants/icons';
import { MODALS, TRANSACTIONS } from 'lbry-redux';
import TransactionListItem from './internal/transaction-list-item'; import TransactionListItem from './internal/transaction-list-item';
export type Transaction = { export type Transaction = {
@ -62,7 +61,7 @@ class TransactionList extends React.PureComponent<Props> {
} }
revokeClaim(txid: string, nout: number) { revokeClaim(txid: string, nout: number) {
this.props.openModal(MODALS.CONFIRM_CLAIM_REVOKE, { txid, nout }); this.props.openModal({ id: MODALS.CONFIRM_CLAIM_REVOKE }, { txid, nout });
} }
render() { render() {
@ -101,7 +100,7 @@ class TransactionList extends React.PureComponent<Props> {
postfix={ postfix={
<Button <Button
button="link" button="link"
icon={ICONS.HELP} icon={icons.HELP}
href="https://lbry.io/faq/transaction-types" href="https://lbry.io/faq/transaction-types"
title={__('Help')} title={__('Help')}
/> />

View file

@ -1,6 +1,5 @@
import * as MODALS from 'constants/modal_types';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doOpenModal } from 'redux/actions/app'; import { doNotify, MODALS } from 'lbry-redux';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import { import {
doUserIdentityVerify, doUserIdentityVerify,
@ -24,7 +23,7 @@ const select = state => {
const perform = dispatch => ({ const perform = dispatch => ({
navigate: uri => dispatch(doNavigate(uri)), navigate: uri => dispatch(doNavigate(uri)),
verifyUserIdentity: token => dispatch(doUserIdentityVerify(token)), verifyUserIdentity: token => dispatch(doUserIdentityVerify(token)),
verifyPhone: () => dispatch(doOpenModal(MODALS.PHONE_COLLECTION)), verifyPhone: () => dispatch(doNotify({ id: MODALS.PHONE_COLLECTION })),
}); });
export default connect( export default connect(

View file

@ -1,10 +1,9 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectBalance } from 'lbry-redux'; import { selectBalance, doNotify } from 'lbry-redux';
import { doOpenModal } from 'redux/actions/app';
import WalletSend from './view'; import WalletSend from './view';
const perform = dispatch => ({ const perform = dispatch => ({
openModal: (modal, props) => dispatch(doOpenModal(modal, props)), openModal: (modal, props) => dispatch(doNotify(modal, props)),
}); });
const select = state => ({ const select = state => ({

View file

@ -1,6 +1,6 @@
// @flow // @flow
import React from 'react'; import React from 'react';
import * as MODALS from 'constants/modal_types'; import { MODALS } from 'lbry-redux';
import Button from 'component/button'; import Button from 'component/button';
import { Form, FormRow, FormField } from 'component/common/form'; import { Form, FormRow, FormField } from 'component/common/form';
import { Formik } from 'formik'; import { Formik } from 'formik';
@ -27,8 +27,9 @@ class WalletSend extends React.PureComponent<Props> {
const { openModal } = this.props; const { openModal } = this.props;
const { address, amount } = values; const { address, amount } = values;
if (amount && address) { if (amount && address) {
const notificationId = { id: MODALS.CONFIRM_TRANSACTION };
const modalProps = { address, amount }; const modalProps = { address, amount };
openModal(MODALS.CONFIRM_TRANSACTION, modalProps); openModal(notificationId, modalProps);
} }
} }

View file

@ -7,7 +7,7 @@ import {
doFocusSearchInput, doFocusSearchInput,
doBlurSearchInput, doBlurSearchInput,
doSearch, doSearch,
doToast, doNotify,
} from 'lbry-redux'; } from 'lbry-redux';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import * as settings from 'constants/settings'; import * as settings from 'constants/settings';
@ -39,7 +39,7 @@ const perform = dispatch => ({
updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)), updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)),
doFocus: () => dispatch(doFocusSearchInput()), doFocus: () => dispatch(doFocusSearchInput()),
doBlur: () => dispatch(doBlurSearchInput()), doBlur: () => dispatch(doBlurSearchInput()),
doShowSnackBar: (props) => dispatch(doToast(props)), doShowSnackBar: (modal, props) => dispatch(doNotify(modal, props)),
}); });
export default connect( export default connect(

View file

@ -107,6 +107,7 @@ class WunderBar extends React.PureComponent<Props> {
} else { } else {
this.props.doShowSnackBar({ this.props.doShowSnackBar({
message: __('Invalid LBRY URL entered. Only A-Z, a-z, and - allowed.'), message: __('Invalid LBRY URL entered. Only A-Z, a-z, and - allowed.'),
displayType: ['snackbar'],
}); });
} }

View file

@ -13,8 +13,6 @@ export const DAEMON_READY = 'DAEMON_READY';
export const DAEMON_VERSION_MATCH = 'DAEMON_VERSION_MATCH'; export const DAEMON_VERSION_MATCH = 'DAEMON_VERSION_MATCH';
export const DAEMON_VERSION_MISMATCH = 'DAEMON_VERSION_MISMATCH'; export const DAEMON_VERSION_MISMATCH = 'DAEMON_VERSION_MISMATCH';
export const VOLUME_CHANGED = 'VOLUME_CHANGED'; export const VOLUME_CHANGED = 'VOLUME_CHANGED';
export const SHOW_MODAL = 'SHOW_MODAL';
export const HIDE_MODAL = 'HIDE_MODAL';
// Navigation // Navigation
export const CHANGE_AFTER_AUTH_PATH = 'CHANGE_AFTER_AUTH_PATH'; export const CHANGE_AFTER_AUTH_PATH = 'CHANGE_AFTER_AUTH_PATH';

View file

@ -1,30 +0,0 @@
export const CONFIRM_FILE_REMOVE = 'confirm_file_remove';
export const CONFIRM_EXTERNAL_LINK = 'confirm_external_link';
export const INCOMPATIBLE_DAEMON = 'incompatible_daemon';
export const FILE_TIMEOUT = 'file_timeout';
export const DOWNLOADING = 'downloading';
export const AUTO_UPDATE_DOWNLOADED = 'auto_update_downloaded';
export const AUTO_UPDATE_CONFIRM = 'auto_update_confirm';
export const ERROR = 'error';
export const INSUFFICIENT_CREDITS = 'insufficient_credits';
export const UPGRADE = 'upgrade';
export const WELCOME = 'welcome';
export const EMAIL_COLLECTION = 'email_collection';
export const PHONE_COLLECTION = 'phone_collection';
export const FIRST_REWARD = 'first_reward';
export const AUTHENTICATION_FAILURE = 'auth_failure';
export const TRANSACTION_FAILED = 'transaction_failed';
export const REWARD_APPROVAL_REQUIRED = 'reward_approval_required';
export const REWARD_GENERATED_CODE = 'reward_generated_code';
export const AFFIRM_PURCHASE = 'affirm_purchase';
export const CONFIRM_CLAIM_REVOKE = 'confirm_claim_revoke';
export const FIRST_SUBSCRIPTION = 'firstSubscription';
export const SEND_TIP = 'send_tip';
export const SOCIAL_SHARE = 'social_share';
export const PUBLISH = 'publish';
export const SEARCH = 'search';
export const CONFIRM_TRANSACTION = 'confirm_transaction';
export const CONFIRM_THUMBNAIL_UPLOAD = 'confirm_thumbnail_upload';
export const WALLET_ENCRYPT = 'wallet_encrypt';
export const WALLET_DECRYPT = 'wallet_decrypt';
export const WALLET_UNLOCK = 'wallet_unlock';

View file

@ -10,7 +10,7 @@ import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import { doConditionalAuthNavigate, doDaemonReady, doAutoUpdate } from 'redux/actions/app'; import { doConditionalAuthNavigate, doDaemonReady, doAutoUpdate } from 'redux/actions/app';
import { doToast, doBlackListedOutpointsSubscribe, isURIValid } from 'lbry-redux'; import { doNotify, doBlackListedOutpointsSubscribe, isURIValid } from 'lbry-redux';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import { doDownloadLanguages, doUpdateIsNightAsync } from 'redux/actions/settings'; import { doDownloadLanguages, doUpdateIsNightAsync } from 'redux/actions/settings';
import { doUserEmailVerify, doAuthenticate, Lbryio } from 'lbryinc'; import { doUserEmailVerify, doAuthenticate, Lbryio } from 'lbryinc';
@ -74,8 +74,9 @@ ipcRenderer.on('open-uri-requested', (event, uri, newSession) => {
app.store.dispatch(doUserEmailVerify(verification.token, verification.recaptcha)); app.store.dispatch(doUserEmailVerify(verification.token, verification.recaptcha));
} else { } else {
app.store.dispatch( app.store.dispatch(
doToast({ doNotify({
message: 'Invalid Verification URI', message: 'Invalid Verification URI',
displayType: ['snackbar'],
}) })
); );
} }
@ -86,8 +87,9 @@ ipcRenderer.on('open-uri-requested', (event, uri, newSession) => {
app.store.dispatch(doNavigate('/show', { uri })); app.store.dispatch(doNavigate('/show', { uri }));
} else { } else {
app.store.dispatch( app.store.dispatch(
doToast({ doNotify({
message: __('Invalid LBRY URL requested'), message: __('Invalid LBRY URL requested'),
displayType: ['snackbar'],
}) })
); );
} }

View file

@ -1,7 +1,6 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doLoadVideo, doSetPlayingUri } from 'redux/actions/content'; import { doLoadVideo, doSetPlayingUri } from 'redux/actions/content';
import { doHideModal } from 'redux/actions/app'; import { doHideNotification, makeSelectMetadataForUri } from 'lbry-redux';
import { makeSelectMetadataForUri } from 'lbry-redux';
import ModalAffirmPurchase from './view'; import ModalAffirmPurchase from './view';
const select = (state, props) => ({ const select = (state, props) => ({
@ -11,9 +10,9 @@ const select = (state, props) => ({
const perform = dispatch => ({ const perform = dispatch => ({
cancelPurchase: () => { cancelPurchase: () => {
dispatch(doSetPlayingUri(null)); dispatch(doSetPlayingUri(null));
dispatch(doHideModal()); dispatch(doHideNotification());
}, },
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
loadVideo: uri => dispatch(doLoadVideo(uri)), loadVideo: uri => dispatch(doLoadVideo(uri)),
}); });

View file

@ -1,11 +1,11 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideNotification } from 'lbry-redux';
import ModalAuthFailure from './view'; import ModalAuthFailure from './view';
const select = () => ({}); const select = () => ({});
const perform = dispatch => ({ const perform = dispatch => ({
close: () => dispatch(doHideModal()), close: () => dispatch(doHideNotification()),
}); });
export default connect( export default connect(

View file

@ -1,9 +1,10 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doAutoUpdateDeclined, doHideModal } from 'redux/actions/app'; import { doAutoUpdateDeclined } from 'redux/actions/app';
import { doHideNotification } from 'lbry-redux';
import ModalAutoUpdateConfirm from './view'; import ModalAutoUpdateConfirm from './view';
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
declineAutoUpdate: () => dispatch(doAutoUpdateDeclined()), declineAutoUpdate: () => dispatch(doAutoUpdateDeclined()),
}); });

View file

@ -1,9 +1,10 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doAutoUpdateDeclined, doHideModal } from 'redux/actions/app'; import { doAutoUpdateDeclined } from 'redux/actions/app';
import { doHideNotification } from 'lbry-redux';
import ModalAutoUpdateDownloaded from './view'; import ModalAutoUpdateDownloaded from './view';
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
declineAutoUpdate: () => dispatch(doAutoUpdateDeclined()), declineAutoUpdate: () => dispatch(doAutoUpdateDeclined()),
}); });

View file

@ -1,5 +1,5 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideNotification } from 'lbry-redux';
import { doUploadThumbnail, doUpdatePublishForm } from 'redux/actions/publish'; import { doUploadThumbnail, doUpdatePublishForm } from 'redux/actions/publish';
import { selectPublishFormValues } from 'redux/selectors/publish'; import { selectPublishFormValues } from 'redux/selectors/publish';
import ModalConfirmThumbnailUpload from './view'; import ModalConfirmThumbnailUpload from './view';
@ -10,7 +10,7 @@ const select = state => {
}; };
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
upload: (path, nsfw = false) => dispatch(doUploadThumbnail(path, nsfw)), upload: (path, nsfw = false) => dispatch(doUploadThumbnail(path, nsfw)),
updatePublishForm: value => dispatch(doUpdatePublishForm(value)), updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
}); });

View file

@ -1,10 +1,9 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doSendDraftTransaction } from 'lbry-redux'; import { doHideNotification, doSendDraftTransaction } from 'lbry-redux';
import { doHideModal } from 'redux/actions/app';
import ModalConfirmTransaction from './view'; import ModalConfirmTransaction from './view';
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
sendToAddress: (address, amount) => dispatch(doSendDraftTransaction(address, amount)), sendToAddress: (address, amount) => dispatch(doSendDraftTransaction(address, amount)),
}); });

View file

@ -2,8 +2,7 @@ import { connect } from 'react-redux';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import { doSetClientSetting } from 'redux/actions/settings'; import { doSetClientSetting } from 'redux/actions/settings';
import { selectUserIsRewardApproved, selectUnclaimedRewardValue } from 'lbryinc'; import { selectUserIsRewardApproved, selectUnclaimedRewardValue } from 'lbryinc';
import { selectBalance } from 'lbry-redux'; import { selectBalance, doHideNotification } from 'lbry-redux';
import { doHideModal } from 'redux/actions/app';
import * as settings from 'constants/settings'; import * as settings from 'constants/settings';
import ModalCreditIntro from './view'; import ModalCreditIntro from './view';
@ -17,11 +16,11 @@ const perform = dispatch => () => ({
addBalance: () => { addBalance: () => {
dispatch(doSetClientSetting(settings.CREDIT_REQUIRED_ACKNOWLEDGED, true)); dispatch(doSetClientSetting(settings.CREDIT_REQUIRED_ACKNOWLEDGED, true));
dispatch(doNavigate('/getcredits')); dispatch(doNavigate('/getcredits'));
dispatch(doHideModal()); dispatch(doHideNotification());
}, },
closeModal: () => { closeModal: () => {
dispatch(doSetClientSetting(settings.CREDIT_REQUIRED_ACKNOWLEDGED, true)); dispatch(doSetClientSetting(settings.CREDIT_REQUIRED_ACKNOWLEDGED, true));
dispatch(doHideModal()); dispatch(doHideNotification());
}, },
}); });

View file

@ -1,5 +1,6 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doStartUpgrade, doCancelUpgrade, doHideModal } from 'redux/actions/app'; import { doStartUpgrade, doCancelUpgrade } from 'redux/actions/app';
import { doHideNotification } from 'lbry-redux';
import { import {
selectDownloadProgress, selectDownloadProgress,
selectDownloadComplete, selectDownloadComplete,
@ -16,7 +17,7 @@ const select = state => ({
const perform = dispatch => ({ const perform = dispatch => ({
startUpgrade: () => dispatch(doStartUpgrade()), startUpgrade: () => dispatch(doStartUpgrade()),
cancelUpgrade: () => { cancelUpgrade: () => {
dispatch(doHideModal()); dispatch(doHideNotification());
dispatch(doCancelUpgrade()); dispatch(doCancelUpgrade());
}, },
}); });

View file

@ -1,6 +1,6 @@
import * as settings from 'constants/settings'; import * as settings from 'constants/settings';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideNotification } from 'lbry-redux';
import { doSetClientSetting } from 'redux/actions/settings'; import { doSetClientSetting } from 'redux/actions/settings';
import { selectEmailToVerify, selectUser } from 'lbryinc'; import { selectEmailToVerify, selectUser } from 'lbryinc';
import ModalEmailCollection from './view'; import ModalEmailCollection from './view';
@ -13,7 +13,7 @@ const select = state => ({
const perform = dispatch => () => ({ const perform = dispatch => () => ({
closeModal: () => { closeModal: () => {
dispatch(doSetClientSetting(settings.EMAIL_COLLECTION_ACKNOWLEDGED, true)); dispatch(doSetClientSetting(settings.EMAIL_COLLECTION_ACKNOWLEDGED, true));
dispatch(doHideModal()); dispatch(doHideNotification());
}, },
}); });

View file

@ -1,9 +1,9 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doDismissError } from 'lbry-redux'; import { doHideNotification } from 'lbry-redux';
import ModalError from './view'; import ModalError from './view';
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doDismissError()), closeModal: () => dispatch(doHideNotification()),
}); });
export default connect(null, perform)(ModalError); export default connect(null, perform)(ModalError);

View file

@ -1,6 +1,5 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { makeSelectMetadataForUri } from 'lbry-redux'; import { doHideNotification, makeSelectMetadataForUri } from 'lbry-redux';
import { doHideModal } from 'redux/actions/app';
import ModalFileTimeout from './view'; import ModalFileTimeout from './view';
const select = (state, props) => ({ const select = (state, props) => ({
@ -8,7 +7,7 @@ const select = (state, props) => ({
}); });
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
}); });
export default connect(select, perform)(ModalFileTimeout); export default connect(select, perform)(ModalFileTimeout);

View file

@ -1,6 +1,6 @@
import { rewards, makeSelectRewardByType } from 'lbryinc'; import { rewards, makeSelectRewardByType } from 'lbryinc';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideNotification } from 'lbry-redux';
import ModalFirstReward from './view'; import ModalFirstReward from './view';
const select = state => { const select = state => {
@ -12,7 +12,7 @@ const select = state => {
}; };
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
}); });
export default connect( export default connect(

View file

@ -1,10 +1,10 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideNotification } from 'lbry-redux';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import ModalFirstSubscription from './view'; import ModalFirstSubscription from './view';
const perform = dispatch => () => ({ const perform = dispatch => () => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
navigate: path => dispatch(doNavigate(path)), navigate: path => dispatch(doNavigate(path)),
}); });

View file

@ -1,9 +1,9 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideNotification } from 'lbry-redux';
import ModalOpenExternalLink from './view'; import ModalOpenExternalLink from './view';
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
}); });
export default connect(null, perform)(ModalOpenExternalLink); export default connect(null, perform)(ModalOpenExternalLink);

View file

@ -1,5 +1,5 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideNotification } from 'lbry-redux';
import { selectPhoneToVerify, selectUser } from 'lbryinc'; import { selectPhoneToVerify, selectUser } from 'lbryinc';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import ModalPhoneCollection from './view'; import ModalPhoneCollection from './view';
@ -11,7 +11,7 @@ const select = state => ({
const perform = dispatch => () => ({ const perform = dispatch => () => ({
closeModal: () => { closeModal: () => {
dispatch(doHideModal()); dispatch(doHideNotification());
dispatch(doNavigate('/rewards')); dispatch(doNavigate('/rewards'));
}, },
}); });

View file

@ -1,11 +1,11 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideNotification } from 'lbry-redux';
import ModalSendTip from './view'; import ModalSendTip from './view';
import { doClearPublish } from 'redux/actions/publish'; import { doClearPublish } from 'redux/actions/publish';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
clearPublish: () => dispatch(doClearPublish()), clearPublish: () => dispatch(doClearPublish()),
navigate: (path, params) => dispatch(doNavigate(path, params)), navigate: (path, params) => dispatch(doNavigate(path, params)),
}); });

View file

@ -1,11 +1,11 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doDeleteFileAndGoBack } from 'redux/actions/file'; import { doDeleteFileAndGoBack } from 'redux/actions/file';
import { import {
doHideNotification,
makeSelectTitleForUri, makeSelectTitleForUri,
makeSelectClaimIsMine, makeSelectClaimIsMine,
makeSelectFileInfoForUri, makeSelectFileInfoForUri,
} from 'lbry-redux'; } from 'lbry-redux';
import { doHideModal } from 'redux/actions/app';
import ModalRemoveFile from './view'; import ModalRemoveFile from './view';
const select = (state, props) => ({ const select = (state, props) => ({
@ -15,7 +15,7 @@ const select = (state, props) => ({
}); });
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
deleteFile: (fileInfo, deleteFromComputer, abandonClaim) => { deleteFile: (fileInfo, deleteFromComputer, abandonClaim) => {
dispatch(doDeleteFileAndGoBack(fileInfo, deleteFromComputer, abandonClaim)); dispatch(doDeleteFileAndGoBack(fileInfo, deleteFromComputer, abandonClaim));
}, },

View file

@ -1,6 +1,5 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideNotification, doAbandonClaim, selectTransactionItems } from 'lbry-redux';
import { doAbandonClaim, selectTransactionItems } from 'lbry-redux';
import ModalRevokeClaim from './view'; import ModalRevokeClaim from './view';
const select = state => ({ const select = state => ({
@ -8,7 +7,7 @@ const select = state => ({
}); });
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
abandonClaim: (txid, nout) => dispatch(doAbandonClaim(txid, nout)), abandonClaim: (txid, nout) => dispatch(doAbandonClaim(txid, nout)),
}); });

View file

@ -1,14 +1,14 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideNotification } from 'lbry-redux';
import { doAuthNavigate } from 'redux/actions/navigation'; import { doAuthNavigate } from 'redux/actions/navigation';
import ModalRewardApprovalRequired from './view'; import ModalRewardApprovalRequired from './view';
const perform = dispatch => ({ const perform = dispatch => ({
doAuth: () => { doAuth: () => {
dispatch(doHideModal()); dispatch(doHideNotification());
dispatch(doAuthNavigate()); dispatch(doAuthNavigate());
}, },
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
}); });
export default connect(null, perform)(ModalRewardApprovalRequired); export default connect(null, perform)(ModalRewardApprovalRequired);

View file

@ -1,6 +1,6 @@
// @flow // @flow
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideNotification } from 'lbry-redux';
import { import {
makeSelectClaimRewardError, makeSelectClaimRewardError,
doClaimRewardType, doClaimRewardType,
@ -17,7 +17,7 @@ const select = (state): {} => ({
}); });
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
submitRewardCode: (code: string) => submitRewardCode: (code: string) =>
dispatch(doClaimRewardType(REWARD_TYPES.TYPE_REWARD_CODE, { params: { code } })), dispatch(doClaimRewardType(REWARD_TYPES.TYPE_REWARD_CODE, { params: { code } })),
}); });

View file

@ -1,15 +1,15 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import * as settings from 'constants/settings'; import * as settings from 'constants/settings';
import { import {
doNotify,
selectCostForCurrentPageUri, selectCostForCurrentPageUri,
selectBalance, selectBalance,
selectCurrentPage, selectCurrentPage,
selectError, selectNotification,
doToast selectNotificationProps,
} from 'lbry-redux'; } from 'lbry-redux';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import { selectUser, selectUserIsVerificationCandidate } from 'lbryinc'; import { selectUser, selectUserIsVerificationCandidate } from 'lbryinc';
import { selectModal } from 'redux/selectors/app';
import ModalRouter from './view'; import ModalRouter from './view';
@ -24,12 +24,12 @@ const select = state => ({
), ),
isWelcomeAcknowledged: makeSelectClientSetting(settings.NEW_USER_ACKNOWLEDGED)(state), isWelcomeAcknowledged: makeSelectClientSetting(settings.NEW_USER_ACKNOWLEDGED)(state),
user: selectUser(state), user: selectUser(state),
modal: selectModal(state), notification: selectNotification(state),
error: selectError(state), notificationProps: selectNotificationProps(state),
}); });
const perform = dispatch => ({ const perform = dispatch => ({
showToast: props => dispatch(doToast(props)), openModal: notification => dispatch(doNotify(notification)),
}); });
export default connect( export default connect(

View file

@ -1,6 +1,6 @@
// @flow // @flow
import React from 'react'; import React from 'react';
import * as MODALS from 'constants/modal_types'; import { MODALS } from 'lbry-redux';
import ModalError from 'modal/modalError'; import ModalError from 'modal/modalError';
import ModalAuthFailure from 'modal/modalAuthFailure'; import ModalAuthFailure from 'modal/modalAuthFailure';
import ModalDownloading from 'modal/modalDownloading'; import ModalDownloading from 'modal/modalDownloading';
@ -70,7 +70,7 @@ class ModalRouter extends React.PureComponent<Props> {
transitionModal && transitionModal &&
(transitionModal !== this.state.lastTransitionModal || page !== this.state.lastTransitionPage) (transitionModal !== this.state.lastTransitionModal || page !== this.state.lastTransitionPage)
) { ) {
openModal(transitionModal); openModal({ id: transitionModal });
this.setState({ this.setState({
lastTransitionModal: transitionModal, lastTransitionModal: transitionModal,
lastTransitionPage: page, lastTransitionPage: page,
@ -121,75 +121,73 @@ class ModalRouter extends React.PureComponent<Props> {
} }
render() { render() {
const { modal, error } = this.props; const { notification, notificationProps } = this.props;
if (error) { if (!notification) {
return <ModalError {...error} />;
}
if (!modal) {
return null; return null;
} }
const { id, modalProps } = modal; if (notification.error) {
return <ModalError {...notification} {...notificationProps} />;
}
switch (id) { switch (notification.id) {
case MODALS.UPGRADE: case MODALS.UPGRADE:
return <ModalUpgrade {...modalProps} />; return <ModalUpgrade {...notificationProps} />;
case MODALS.DOWNLOADING: case MODALS.DOWNLOADING:
return <ModalDownloading {...modalProps} />; return <ModalDownloading {...notificationProps} />;
case MODALS.AUTO_UPDATE_DOWNLOADED: case MODALS.AUTO_UPDATE_DOWNLOADED:
return <ModalAutoUpdateDownloaded {...modalProps} />; return <ModalAutoUpdateDownloaded {...notificationProps} />;
case MODALS.AUTO_UPDATE_CONFIRM: case MODALS.AUTO_UPDATE_CONFIRM:
return <ModalAutoUpdateConfirm {...modalProps} />; return <ModalAutoUpdateConfirm {...notificationProps} />;
case MODALS.ERROR: case MODALS.ERROR:
return <ModalError {...modalProps} />; return <ModalError {...notificationProps} />;
case MODALS.FILE_TIMEOUT: case MODALS.FILE_TIMEOUT:
return <ModalFileTimeout {...modalProps} />; return <ModalFileTimeout {...notificationProps} />;
case MODALS.INSUFFICIENT_CREDITS: case MODALS.INSUFFICIENT_CREDITS:
return <ModalCreditIntro {...modalProps} />; return <ModalCreditIntro {...notificationProps} />;
case MODALS.WELCOME: case MODALS.WELCOME:
return <ModalWelcome {...modalProps} />; return <ModalWelcome {...notificationProps} />;
case MODALS.FIRST_REWARD: case MODALS.FIRST_REWARD:
return <ModalFirstReward {...modalProps} />; return <ModalFirstReward {...notificationProps} />;
case MODALS.AUTHENTICATION_FAILURE: case MODALS.AUTHENTICATION_FAILURE:
return <ModalAuthFailure {...modalProps} />; return <ModalAuthFailure {...notificationProps} />;
case MODALS.TRANSACTION_FAILED: case MODALS.TRANSACTION_FAILED:
return <ModalTransactionFailed {...modalProps} />; return <ModalTransactionFailed {...notificationProps} />;
case MODALS.REWARD_APPROVAL_REQUIRED: case MODALS.REWARD_APPROVAL_REQUIRED:
return <ModalRewardApprovalRequired {...modalProps} />; return <ModalRewardApprovalRequired {...notificationProps} />;
case MODALS.CONFIRM_FILE_REMOVE: case MODALS.CONFIRM_FILE_REMOVE:
return <ModalRemoveFile {...modalProps} />; return <ModalRemoveFile {...notificationProps} />;
case MODALS.AFFIRM_PURCHASE: case MODALS.AFFIRM_PURCHASE:
return <ModalAffirmPurchase {...modalProps} />; return <ModalAffirmPurchase {...notificationProps} />;
case MODALS.CONFIRM_CLAIM_REVOKE: case MODALS.CONFIRM_CLAIM_REVOKE:
return <ModalRevokeClaim {...modalProps} />; return <ModalRevokeClaim {...notificationProps} />;
case MODALS.PHONE_COLLECTION: case MODALS.PHONE_COLLECTION:
return <ModalPhoneCollection {...modalProps} />; return <ModalPhoneCollection {...notificationProps} />;
case MODALS.EMAIL_COLLECTION: case MODALS.EMAIL_COLLECTION:
return <ModalEmailCollection {...modalProps} />; return <ModalEmailCollection {...notificationProps} />;
case MODALS.FIRST_SUBSCRIPTION: case MODALS.FIRST_SUBSCRIPTION:
return <ModalFirstSubscription {...modalProps} />; return <ModalFirstSubscription {...notificationProps} />;
case MODALS.SEND_TIP: case MODALS.SEND_TIP:
return <ModalSendTip {...modalProps} />; return <ModalSendTip {...notificationProps} />;
case MODALS.SOCIAL_SHARE: case MODALS.SOCIAL_SHARE:
return <ModalSocialShare {...modalProps} />; return <ModalSocialShare {...notificationProps} />;
case MODALS.PUBLISH: case MODALS.PUBLISH:
return <ModalPublish {...modalProps} />; return <ModalPublish {...notificationProps} />;
case MODALS.CONFIRM_EXTERNAL_LINK: case MODALS.CONFIRM_EXTERNAL_LINK:
return <ModalOpenExternalLink {...modalProps} />; return <ModalOpenExternalLink {...notificationProps} />;
case MODALS.CONFIRM_TRANSACTION: case MODALS.CONFIRM_TRANSACTION:
return <ModalConfirmTransaction {...modalProps} />; return <ModalConfirmTransaction {...notificationProps} />;
case MODALS.CONFIRM_THUMBNAIL_UPLOAD: case MODALS.CONFIRM_THUMBNAIL_UPLOAD:
return <ModalConfirmThumbnailUpload {...modalProps} />; return <ModalConfirmThumbnailUpload {...notificationProps} />;
case MODALS.WALLET_ENCRYPT: case MODALS.WALLET_ENCRYPT:
return <ModalWalletEncrypt {...modalProps} />; return <ModalWalletEncrypt {...notificationProps} />;
case MODALS.WALLET_DECRYPT: case MODALS.WALLET_DECRYPT:
return <ModalWalletDecrypt {...modalProps} />; return <ModalWalletDecrypt {...notificationProps} />;
case MODALS.WALLET_UNLOCK: case MODALS.WALLET_UNLOCK:
return <ModalWalletUnlock {...modalProps} />; return <ModalWalletUnlock {...notificationProps} />;
case MODALS.REWARD_GENERATED_CODE: case MODALS.REWARD_GENERATED_CODE:
return <ModalRewardCode {...modalProps} />; return <ModalRewardCode {...notificationProps} />;
default: default:
return null; return null;
} }

View file

@ -1,9 +1,9 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideNotification } from 'lbry-redux';
import ModalSendTip from './view'; import ModalSendTip from './view';
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
}); });
export default connect(null, perform)(ModalSendTip); export default connect(null, perform)(ModalSendTip);

View file

@ -1,9 +1,9 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideNotification } from 'lbry-redux';
import ModalSocialShare from './view'; import ModalSocialShare from './view';
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
}); });
export default connect( export default connect(

View file

@ -1,11 +1,11 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideNotification } from 'lbry-redux';
import ModalTransactionFailed from './view'; import ModalTransactionFailed from './view';
const select = () => ({}); const select = () => ({});
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
}); });
export default connect( export default connect(

View file

@ -1,5 +1,6 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doDownloadUpgrade, doSkipUpgrade, doHideModal } from 'redux/actions/app'; import { doHideNotification } from 'lbry-redux';
import { doDownloadUpgrade, doSkipUpgrade } from 'redux/actions/app';
import ModalUpgrade from './view'; import ModalUpgrade from './view';
const select = () => ({}); const select = () => ({});
@ -7,7 +8,7 @@ const select = () => ({});
const perform = dispatch => ({ const perform = dispatch => ({
downloadUpgrade: () => dispatch(doDownloadUpgrade()), downloadUpgrade: () => dispatch(doDownloadUpgrade()),
skipUpgrade: () => { skipUpgrade: () => {
dispatch(doHideModal()); dispatch(doHideNotification());
dispatch(doSkipUpgrade()); dispatch(doSkipUpgrade());
}, },
}); });

View file

@ -1,10 +1,10 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { import {
doHideNotification,
doWalletStatus, doWalletStatus,
doWalletDecrypt, doWalletDecrypt,
selectWalletDecryptSucceeded, selectWalletDecryptSucceeded,
} from 'lbry-redux'; } from 'lbry-redux';
import { doHideModal } from 'redux/actions/app';
import ModalWalletDecrypt from './view'; import ModalWalletDecrypt from './view';
const select = state => ({ const select = state => ({
@ -12,7 +12,7 @@ const select = state => ({
}); });
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
decryptWallet: password => dispatch(doWalletDecrypt(password)), decryptWallet: password => dispatch(doWalletDecrypt(password)),
updateWalletStatus: () => dispatch(doWalletStatus()), updateWalletStatus: () => dispatch(doWalletStatus()),
}); });

View file

@ -1,12 +1,12 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { import {
doHideNotification,
doWalletStatus, doWalletStatus,
doWalletEncrypt, doWalletEncrypt,
selectWalletEncryptPending, selectWalletEncryptPending,
selectWalletEncryptSucceeded, selectWalletEncryptSucceeded,
selectWalletEncryptResult, selectWalletEncryptResult,
} from 'lbry-redux'; } from 'lbry-redux';
import { doHideModal } from 'redux/actions/app';
import ModalWalletEncrypt from './view'; import ModalWalletEncrypt from './view';
const select = state => ({ const select = state => ({
@ -15,7 +15,7 @@ const select = state => ({
}); });
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
encryptWallet: password => dispatch(doWalletEncrypt(password)), encryptWallet: password => dispatch(doWalletEncrypt(password)),
updateWalletStatus: () => dispatch(doWalletStatus()), updateWalletStatus: () => dispatch(doWalletStatus()),
}); });

View file

@ -1,10 +1,11 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { import {
doHideNotification,
doWalletUnlock, doWalletUnlock,
selectWalletUnlockPending, selectWalletUnlockPending,
selectWalletUnlockSucceeded, selectWalletUnlockSucceeded,
} from 'lbry-redux'; } from 'lbry-redux';
import { doQuit, doHideModal } from 'redux/actions/app'; import { doQuit } from 'redux/actions/app';
import ModalWalletUnlock from './view'; import ModalWalletUnlock from './view';
const select = state => ({ const select = state => ({
@ -12,7 +13,7 @@ const select = state => ({
}); });
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doHideModal()), closeModal: () => dispatch(doHideNotification()),
quit: () => dispatch(doQuit()), quit: () => dispatch(doQuit()),
unlockWallet: password => dispatch(doWalletUnlock(password)), unlockWallet: password => dispatch(doWalletUnlock(password)),
}); });

View file

@ -1,13 +1,13 @@
import * as settings from 'constants/settings'; import * as settings from 'constants/settings';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideNotification } from 'lbry-redux';
import { doSetClientSetting } from 'redux/actions/settings'; import { doSetClientSetting } from 'redux/actions/settings';
import ModalWelcome from './view'; import ModalWelcome from './view';
const perform = dispatch => () => ({ const perform = dispatch => () => ({
closeModal: () => { closeModal: () => {
dispatch(doSetClientSetting(settings.NEW_USER_ACKNOWLEDGED, true)); dispatch(doSetClientSetting(settings.NEW_USER_ACKNOWLEDGED, true));
dispatch(doHideModal()); dispatch(doHideNotification());
}, },
}); });

View file

@ -14,12 +14,12 @@ import {
makeSelectClaimForUri, makeSelectClaimForUri,
makeSelectContentTypeForUri, makeSelectContentTypeForUri,
makeSelectMetadataForUri, makeSelectMetadataForUri,
doNotify,
makeSelectChannelForClaimUri, makeSelectChannelForClaimUri,
} from 'lbry-redux'; } from 'lbry-redux';
import { selectShowNsfw, makeSelectClientSetting } from 'redux/selectors/settings'; import { selectShowNsfw, makeSelectClientSetting } from 'redux/selectors/settings';
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions'; import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
import { doPrepareEdit } from 'redux/actions/publish'; import { doPrepareEdit } from 'redux/actions/publish';
import { doOpenModal } from 'redux/actions/app';
import FilePage from './view'; import FilePage from './view';
const select = (state, props) => ({ const select = (state, props) => ({
@ -41,7 +41,7 @@ const perform = dispatch => ({
navigate: (path, params) => dispatch(doNavigate(path, params)), navigate: (path, params) => dispatch(doNavigate(path, params)),
fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)), fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)),
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)), fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
openModal: (modal, props) => dispatch(doOpenModal(modal, props)), openModal: (modal, props) => dispatch(doNotify(modal, props)),
prepareEdit: (publishData, uri) => dispatch(doPrepareEdit(publishData, uri)), prepareEdit: (publishData, uri) => dispatch(doPrepareEdit(publishData, uri)),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)), setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
setViewed: uri => dispatch(doSetContentHistoryItem(uri)), setViewed: uri => dispatch(doSetContentHistoryItem(uri)),

View file

@ -3,8 +3,7 @@ import type { Claim, Metadata } from 'types/claim';
import type { FileInfo } from 'types/file_info'; import type { FileInfo } from 'types/file_info';
import * as React from 'react'; import * as React from 'react';
import * as settings from 'constants/settings'; import * as settings from 'constants/settings';
import * as MODALS from 'constants/modal_types'; import { buildURI, normalizeURI, MODALS } from 'lbry-redux';
import { buildURI, normalizeURI } from 'lbry-redux';
import FileViewer from 'component/fileViewer'; import FileViewer from 'component/fileViewer';
import Thumbnail from 'component/common/thumbnail'; import Thumbnail from 'component/common/thumbnail';
import FilePrice from 'component/filePrice'; import FilePrice from 'component/filePrice';
@ -43,7 +42,7 @@ type Props = {
channelUri: string, channelUri: string,
prepareEdit: ({}, string) => void, prepareEdit: ({}, string) => void,
navigate: (string, ?{}) => void, navigate: (string, ?{}) => void,
openModal: (id: string, { uri: string }) => void, openModal: ({ id: string }, { uri: string }) => void,
setClientSetting: (string, string | boolean | number) => void, setClientSetting: (string, string | boolean | number) => void,
markSubscriptionRead: (string, string) => void, markSubscriptionRead: (string, string) => void,
}; };
@ -215,14 +214,14 @@ class FilePage extends React.Component<Props> {
button="alt" button="alt"
icon={icons.GIFT} icon={icons.GIFT}
label={__('Send a tip')} label={__('Send a tip')}
onClick={() => openModal(MODALS.SEND_TIP, { uri })} onClick={() => openModal({ id: MODALS.SEND_TIP }, { uri })}
/> />
)} )}
<Button <Button
button="alt" button="alt"
icon={icons.GLOBE} icon={icons.GLOBE}
label={__('Share')} label={__('Share')}
onClick={() => openModal(MODALS.SOCIAL_SHARE, { uri, speechShareable })} onClick={() => openModal({ id: MODALS.SOCIAL_SHARE }, { uri, speechShareable })}
/> />
</div> </div>

View file

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import Button from 'component/button'; import Button from 'component/button';
import { FormRow, FormField } from 'component/common/form'; import { FormRow, FormField } from 'component/common/form';
import { Lbry, doToast } from 'lbry-redux'; import { Lbry, doNotify } from 'lbry-redux';
import Page from 'component/page'; import Page from 'component/page';
class ReportPage extends React.Component { class ReportPage extends React.Component {
@ -32,7 +32,7 @@ class ReportPage extends React.Component {
}); });
// Display global notice // Display global notice
const action = doToast({ const action = doNotify({
displayType: ['snackbar'], displayType: ['snackbar'],
message: __('Message received! Thanks for helping.'), message: __('Message received! Thanks for helping.'),
isError: false, isError: false,

View file

@ -2,13 +2,15 @@ import { execSync } from 'child_process';
import isDev from 'electron-is-dev'; import isDev from 'electron-is-dev';
import path from 'path'; import path from 'path';
import { ipcRenderer, remote } from 'electron'; import { ipcRenderer, remote } from 'electron';
import * as ACTIONS from 'constants/action_types';
import * as MODALS from 'constants/modal_types';
import { import {
ACTIONS,
Lbry, Lbry,
doBalanceSubscribe, doBalanceSubscribe,
doFetchFileInfosAndPublishedClaims, doFetchFileInfosAndPublishedClaims,
doNotify,
selectNotification, selectNotification,
MODALS,
doHideNotification,
} from 'lbry-redux'; } from 'lbry-redux';
import Native from 'native'; import Native from 'native';
import { doFetchDaemonSettings } from 'redux/actions/settings'; import { doFetchDaemonSettings } from 'redux/actions/settings';
@ -87,9 +89,11 @@ export function doDownloadUpgrade() {
dispatch({ dispatch({
type: ACTIONS.UPGRADE_DOWNLOAD_STARTED, type: ACTIONS.UPGRADE_DOWNLOAD_STARTED,
}); });
dispatch(doHideModal()); dispatch(doHideNotification());
dispatch( dispatch(
doOpenModal(MODALS.DOWNLOADING) doNotify({
id: MODALS.DOWNLOADING,
})
); );
}; };
} }
@ -110,13 +114,17 @@ export function doDownloadUpgradeRequested() {
if (autoUpdateDeclined) { if (autoUpdateDeclined) {
// The user declined an update before, so show the "confirm" dialog // The user declined an update before, so show the "confirm" dialog
dispatch( dispatch(
doOpenModal(MODALS.AUTO_UPDATE_CONFIRM) doNotify({
id: MODALS.AUTO_UPDATE_CONFIRM,
})
); );
} else { } else {
// The user was never shown the original update dialog (e.g. because they were // The user was never shown the original update dialog (e.g. because they were
// watching a video). So show the inital "update downloaded" dialog. // watching a video). So show the inital "update downloaded" dialog.
dispatch( dispatch(
doOpenModal(MODALS.AUTO_UPDATE_DOWNLOADED) doNotify({
id: MODALS.AUTO_UPDATE_DOWNLOADED,
})
); );
} }
} else { } else {
@ -146,7 +154,9 @@ export function doAutoUpdate() {
}); });
dispatch( dispatch(
doOpenModal(MODALS.AUTO_UPDATE_DOWNLOADED) doNotify({
id: MODALS.AUTO_UPDATE_DOWNLOADED,
})
); );
dispatch(doClearUpgradeTimer()); dispatch(doClearUpgradeTimer());
@ -220,7 +230,9 @@ export function doCheckUpgradeAvailable() {
(!selectIsUpgradeSkipped(state) || remoteVersion !== selectRemoteVersion(state)) (!selectIsUpgradeSkipped(state) || remoteVersion !== selectRemoteVersion(state))
) { ) {
dispatch( dispatch(
doOpenModal(MODALS.UPGRADE) doNotify({
id: MODALS.UPGRADE,
})
); );
} }
}; };
@ -267,7 +279,9 @@ export function doCheckDaemonVersion() {
}); });
return dispatch( return dispatch(
doOpenModal(MODALS.INCOMPATIBLE_DAEMON) doNotify({
id: MODALS.INCOMPATIBLE_DAEMON,
})
); );
}); });
}; };
@ -276,7 +290,9 @@ export function doCheckDaemonVersion() {
export function doNotifyEncryptWallet() { export function doNotifyEncryptWallet() {
return dispatch => { return dispatch => {
dispatch( dispatch(
doOpenModal(MODALS.WALLET_ENCRYPT) doNotify({
id: MODALS.WALLET_ENCRYPT,
})
); );
}; };
} }
@ -284,7 +300,9 @@ export function doNotifyEncryptWallet() {
export function doNotifyDecryptWallet() { export function doNotifyDecryptWallet() {
return dispatch => { return dispatch => {
dispatch( dispatch(
doOpenModal(MODALS.WALLET_DECRYPT) doNotify({
id: MODALS.WALLET_DECRYPT,
})
); );
}; };
} }
@ -292,7 +310,9 @@ export function doNotifyDecryptWallet() {
export function doNotifyUnlockWallet() { export function doNotifyUnlockWallet() {
return dispatch => { return dispatch => {
dispatch( dispatch(
doOpenModal(MODALS.WALLET_UNLOCK) doNotify({
id: MODALS.WALLET_UNLOCK,
})
); );
}; };
} }
@ -300,7 +320,10 @@ export function doNotifyUnlockWallet() {
export function doAlertError(errorList) { export function doAlertError(errorList) {
return dispatch => { return dispatch => {
dispatch( dispatch(
doError(errorList) doNotify({
id: MODALS.ERROR,
error: errorList,
})
); );
}; };
} }
@ -374,19 +397,3 @@ export function doConditionalAuthNavigate(newSession) {
} }
}; };
} }
export function doOpenModal(id, modalProps = {}) {
return {
type: ACTIONS.SHOW_MODAL,
data: {
id,
modalProps,
},
};
}
export function doHideModal() {
return {
type: ACTIONS.HIDE_MODAL
}
}

View file

@ -1,8 +1,7 @@
// @flow // @flow
import * as NOTIFICATION_TYPES from 'constants/subscriptions'; import * as NOTIFICATION_TYPES from 'constants/subscriptions';
import * as MODALS from 'constants/modal_types';
import { ipcRenderer } from 'electron'; import { ipcRenderer } from 'electron';
import { doOpenModal } from 'redux/actions/app'; import { doAlertError } from 'redux/actions/app';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import { setSubscriptionLatest, doUpdateUnreadSubscriptions } from 'redux/actions/subscriptions'; import { setSubscriptionLatest, doUpdateUnreadSubscriptions } from 'redux/actions/subscriptions';
import { makeSelectUnreadByChannel } from 'redux/selectors/subscriptions'; import { makeSelectUnreadByChannel } from 'redux/selectors/subscriptions';
@ -20,9 +19,10 @@ import {
selectDownloadingByOutpoint, selectDownloadingByOutpoint,
selectTotalDownloadProgress, selectTotalDownloadProgress,
selectBalance, selectBalance,
MODALS,
doNotify,
makeSelectChannelForClaimUri, makeSelectChannelForClaimUri,
parseURI, parseURI,
doError,
} from 'lbry-redux'; } from 'lbry-redux';
import { makeSelectClientSetting, selectosNotificationsEnabled } from 'redux/selectors/settings'; import { makeSelectClientSetting, selectosNotificationsEnabled } from 'redux/selectors/settings';
import setBadge from 'util/setBadge'; import setBadge from 'util/setBadge';
@ -180,10 +180,10 @@ function handleLoadVideoError(uri, errorType = '') {
}); });
dispatch(doSetPlayingUri(null)); dispatch(doSetPlayingUri(null));
if (errorType === 'timeout') { if (errorType === 'timeout') {
doOpenModal(MODALS.FILE_TIMEOUT, { uri }); doNotify({ id: MODALS.FILE_TIMEOUT }, { uri });
} else { } else {
dispatch( dispatch(
doError( doAlertError(
`Failed to download ${uri}, please try again. If this problem persists, visit https://lbry.io/faq/support for support.` `Failed to download ${uri}, please try again. If this problem persists, visit https://lbry.io/faq/support for support.`
) )
); );
@ -236,7 +236,7 @@ export function doPurchaseUri(uri, specificCostInfo, shouldRecordViewEvent) {
function attemptPlay(cost, instantPurchaseMax = null) { function attemptPlay(cost, instantPurchaseMax = null) {
if (cost > 0 && (!instantPurchaseMax || cost > instantPurchaseMax)) { if (cost > 0 && (!instantPurchaseMax || cost > instantPurchaseMax)) {
dispatch(doOpenModal(MODALS.AFFIRM_PURCHASE, { uri })); dispatch(doNotify({ id: MODALS.AFFIRM_PURCHASE }, { uri }));
} else { } else {
dispatch(doLoadVideo(uri, shouldRecordViewEvent)); dispatch(doLoadVideo(uri, shouldRecordViewEvent));
} }
@ -264,7 +264,7 @@ export function doPurchaseUri(uri, specificCostInfo, shouldRecordViewEvent) {
if (cost > balance) { if (cost > balance) {
dispatch(doSetPlayingUri(null)); dispatch(doSetPlayingUri(null));
dispatch(doOpenModal(MODALS.INSUFFICIENT_CREDITS)); dispatch(doNotify({ id: MODALS.INSUFFICIENT_CREDITS }));
Promise.resolve(); Promise.resolve();
return; return;
} }

View file

@ -7,8 +7,8 @@ import {
selectMyClaimsOutpoints, selectMyClaimsOutpoints,
selectFileInfosByOutpoint, selectFileInfosByOutpoint,
selectTotalDownloadProgress, selectTotalDownloadProgress,
doHideNotification,
} from 'lbry-redux'; } from 'lbry-redux';
import { doHideModal } from 'redux/actions/app';
import { doHistoryBack } from 'redux/actions/navigation'; import { doHistoryBack } from 'redux/actions/navigation';
import setProgressBar from 'util/setProgressBar'; import setProgressBar from 'util/setProgressBar';
@ -65,7 +65,7 @@ export function doDeleteFile(outpoint, deleteFromComputer, abandonClaim) {
export function doDeleteFileAndGoBack(fileInfo, deleteFromComputer, abandonClaim) { export function doDeleteFileAndGoBack(fileInfo, deleteFromComputer, abandonClaim) {
return dispatch => { return dispatch => {
const actions = []; const actions = [];
actions.push(doHideModal()); actions.push(doHideNotification());
actions.push(doHistoryBack()); actions.push(doHistoryBack());
actions.push(doDeleteFile(fileInfo, deleteFromComputer, abandonClaim)); actions.push(doDeleteFile(fileInfo, deleteFromComputer, abandonClaim));
dispatch(batchActions(...actions)); dispatch(batchActions(...actions));

View file

@ -6,17 +6,17 @@ import type {
UpdatePublishFormAction, UpdatePublishFormAction,
PublishParams, PublishParams,
} from 'redux/reducers/publish'; } from 'redux/reducers/publish';
import * as MODALS from 'constants/modal_types';
import { import {
ACTIONS, ACTIONS,
Lbry, Lbry,
doNotify,
MODALS,
selectMyChannelClaims, selectMyChannelClaims,
THUMBNAIL_STATUSES, THUMBNAIL_STATUSES,
batchActions, batchActions,
creditsToString, creditsToString,
selectPendingById, selectPendingById,
} from 'lbry-redux'; } from 'lbry-redux';
import { doOpenModal } from 'redux/actions/app';
import { selectosNotificationsEnabled } from 'redux/selectors/settings'; import { selectosNotificationsEnabled } from 'redux/selectors/settings';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import fs from 'fs'; import fs from 'fs';
@ -97,7 +97,7 @@ export const doUploadThumbnail = (filePath: string, nsfw: boolean) => (
type: ACTIONS.UPDATE_PUBLISH_FORM, type: ACTIONS.UPDATE_PUBLISH_FORM,
data: { uploadThumbnailStatus: THUMBNAIL_STATUSES.API_DOWN }, data: { uploadThumbnailStatus: THUMBNAIL_STATUSES.API_DOWN },
}, },
dispatch(doOpenModal({ id: MODALS.ERROR, error })) dispatch(doNotify({ id: MODALS.ERROR, error }))
) )
); );
@ -266,12 +266,12 @@ export const doPublish = (params: PublishParams) => (
dispatch({ dispatch({
type: ACTIONS.PUBLISH_SUCCESS, type: ACTIONS.PUBLISH_SUCCESS,
}); });
dispatch(doOpenModal(MODALS.PUBLISH, { uri })); dispatch(doNotify({ id: MODALS.PUBLISH }, { uri }));
}; };
const failure = error => { const failure = error => {
dispatch({ type: ACTIONS.PUBLISH_FAIL }); dispatch({ type: ACTIONS.PUBLISH_FAIL });
dispatch(doError(error.message)); dispatch(doNotify({ id: MODALS.ERROR, error: error.message }));
}; };
return Lbry.publish(publishPayload).then(success, failure); return Lbry.publish(publishPayload).then(success, failure);

View file

@ -189,18 +189,6 @@ reducers[ACTIONS.CLEAR_UPGRADE_TIMER] = state =>
checkUpgradeTimer: undefined, checkUpgradeTimer: undefined,
}); });
reducers[ACTIONS.SHOW_MODAL] = (state, action) =>
Object.assign({}, state, {
modal: action.data.id,
modalProps: action.data.modalProps,
});
reducers[ACTIONS.HIDE_MODAL] = (state, action) =>
Object.assign({}, state, {
modal: null,
modalProps: null,
});
export default function reducer(state: AppState = defaultState, action: any) { export default function reducer(state: AppState = defaultState, action: any) {
const handler = reducers[action.type]; const handler = reducers[action.type];
if (handler) return handler(state, action); if (handler) return handler(state, action);

View file

@ -247,14 +247,3 @@ export const selectNavLinks = createSelector(
return navLinks; return navLinks;
} }
); );
export const selectModal = createSelector(selectState, state => {
if (!state.modal) {
return null;
}
return {
id: state.modal,
modalProps: state.modalProps,
};
});

View file

@ -19,10 +19,6 @@
z-index: 10000; // hack to get it over react modal z-index: 10000; // hack to get it over react modal
} }
.snack-bar--error {
background-color: $lbry-red-5;
}
.snack-bar__action { .snack-bar__action {
display: inline-block; display: inline-block;
margin-bottom: 4px; margin-bottom: 4px;