doShowSnackBar => doNotify

This commit is contained in:
Sean Yesmunt 2018-04-19 14:49:47 -04:00
parent 25c6ef54e1
commit 84dc9f45bc
10 changed files with 27 additions and 27 deletions

View file

@ -1,7 +1,7 @@
import { connect } from 'react-redux';
import { doShowSnackBar } from 'redux/actions/app';
import { doNotify } from 'lbry-redux';
import Address from './view';
export default connect(null, {
doShowSnackBar,
doNotify,
})(Address);

View file

@ -7,7 +7,7 @@ import * as icons from 'constants/icons';
type Props = {
address: string,
doShowSnackBar: ({ message: string }) => void,
doNotify: ({ message: string, displayType: Array<string> }) => void,
};
export default class Address extends React.PureComponent<Props> {
@ -20,7 +20,7 @@ export default class Address extends React.PureComponent<Props> {
input: ?HTMLInputElement;
render() {
const { address, doShowSnackBar } = this.props;
const { address, doNotify } = this.props;
return (
<FormRow verticallyCentered padded stretch>
@ -43,7 +43,10 @@ export default class Address extends React.PureComponent<Props> {
icon={icons.CLIPBOARD}
onClick={() => {
clipboard.writeText(address);
doShowSnackBar({ message: __('Address copied') });
doNotify({
message: __('Address copied'),
displayType: ['snackbar']
});
}}
/>
</FormRow>

View file

@ -6,7 +6,7 @@ import {
clearShapeShift,
getActiveShift,
} from 'redux/actions/shape_shift';
import { doShowSnackBar, selectReceiveAddress } from 'lbry-redux';
import { selectReceiveAddress } from 'lbry-redux';
import { selectShapeShift } from 'redux/selectors/shape_shift';
import ShapeShift from './view';
@ -21,5 +21,4 @@ export default connect(select, {
createShapeShift,
clearShapeShift,
getActiveShift,
doShowSnackBar,
})(ShapeShift);

View file

@ -14,7 +14,6 @@ type Props = {
createShapeShift: Dispatch,
clearShapeShift: Dispatch,
getActiveShift: Dispatch,
doShowSnackBar: Dispatch,
shapeShiftInit: Dispatch,
receiveAddress: string,
};
@ -37,7 +36,6 @@ class ShapeShift extends React.PureComponent<Props> {
shapeShift,
clearShapeShift,
getActiveShift,
doShowSnackBar,
} = this.props;
const {
@ -107,7 +105,6 @@ class ShapeShift extends React.PureComponent<Props> {
shiftOrderId={shiftOrderId}
shiftState={shiftState}
clearShapeShift={clearShapeShift}
doShowSnackBar={doShowSnackBar}
originCoinDepositMax={originCoinDepositMax}
originCoinDepositMin={originCoinDepositMin}
originCoinDepositFee={originCoinDepositFee}

View file

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

View file

@ -4,7 +4,7 @@ import Button from 'component/button';
type Props = {
removeSnack: any => void,
snacks: {
snack: ?{
linkTarget: ?string,
linkText: ?string,
message: string,
@ -20,14 +20,13 @@ class SnackBar extends React.PureComponent<Props> {
}
render() {
const { snacks, removeSnack } = this.props;
const { snack, removeSnack } = this.props;
if (!snacks.length) {
if (!snack) {
this.hideTimeout = null; // should be unmounting anyway, but be safe?
return null;
}
const snack = snacks[0];
const { message, linkText, linkTarget } = snack;
if (this.hideTimeout === null) {

View file

@ -10,9 +10,9 @@ import { Provider } from 'react-redux';
import {
doConditionalAuthNavigate,
doDaemonReady,
doShowSnackBar,
doAutoUpdate,
} from 'redux/actions/app';
import { doNotify } from 'lbry-redux';
import { doNavigate } from 'redux/actions/navigation';
import { doDownloadLanguages, doUpdateIsNightAsync } from 'redux/actions/settings';
import { doUserEmailVerify } from 'redux/actions/user';
@ -38,7 +38,10 @@ ipcRenderer.on('open-uri-requested', (event, uri, newSession) => {
app.store.dispatch(doConditionalAuthNavigate(newSession));
app.store.dispatch(doUserEmailVerify(verification.token, verification.recaptcha));
} else {
app.store.dispatch(doShowSnackBar({ message: 'Invalid Verification URI' }));
app.store.dispatch(doNotify({
message: 'Invalid Verification URI',
displayType: ['snackbar']
}));
}
} else {
app.store.dispatch(doNavigate('/show', { uri }));

View file

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

View file

@ -2,7 +2,6 @@ import * as ACTIONS from 'constants/action_types';
import * as MODALS from 'constants/modal_types';
import Lbryio from 'lbryio';
import { doNotify } from 'lbry-redux';
import { doShowSnackBar } from 'redux/actions/app';
import { doClaimRewardType, doRewardList } from 'redux/actions/rewards';
import {
selectEmailToVerify,
@ -293,7 +292,8 @@ export function doUserInviteNew(email) {
});
dispatch(
doShowSnackBar({
doNotify({
displayType: ['snackbar'],
message: __('Invite sent to %s', email),
})
);

View file

@ -1,4 +1,4 @@
import { Lbry, doShowSnackBar } from 'lbry-redux';
import { Lbry, doNotify } from 'lbry-redux';
import Lbryio from 'lbryio';
function rewardMessage(type, amount) {
@ -51,7 +51,7 @@ rewards.claimReward = type => {
const message = rewardMessage(type, reward.reward_amount);
// Display global notice
const action = doShowSnackBar({
const action = doNotify({
message,
linkText: __('Show All'),
linkTarget: '/rewards',