diff --git a/app/src/component/rewardSummary/index.js b/app/src/component/rewardSummary/index.js index 54dd41ef..5c2a7077 100644 --- a/app/src/component/rewardSummary/index.js +++ b/app/src/component/rewardSummary/index.js @@ -1,4 +1,5 @@ import { connect } from 'react-redux'; +import { doNotify } from 'lbry-redux'; import { doRewardList, selectUnclaimedRewardValue, selectFetchingRewards, selectUser } from 'lbryinc'; import RewardSummary from './view'; @@ -10,6 +11,7 @@ const select = state => ({ const perform = dispatch => ({ fetchRewards: () => dispatch(doRewardList()), + notify: data => dispatch(doNotify(data)) }); export default connect(select, perform)(RewardSummary); diff --git a/app/src/component/rewardSummary/view.js b/app/src/component/rewardSummary/view.js index 17c156a7..cbdf50d2 100644 --- a/app/src/component/rewardSummary/view.js +++ b/app/src/component/rewardSummary/view.js @@ -1,32 +1,54 @@ import React from 'react'; -import { NativeModules, Text, TouchableOpacity } from 'react-native'; +import { AsyncStorage, NativeModules, Text, TouchableOpacity } from 'react-native'; +import Button from '../../component/button'; import rewardStyle from '../../styles/reward'; class RewardSummary extends React.Component { + static itemKey = 'rewardSummaryDismissed'; + state = { - actionsLeft: 0 + actionsLeft: 0, + dismissed: false }; componentDidMount() { this.props.fetchRewards(); - const { user } = this.props; - let actionsLeft = 0; - if (!user || !user.has_verified_email) { - actionsLeft++; - } + AsyncStorage.getItem(RewardSummary.itemKey).then(isDismissed => { + if ('true' === isDismissed) { + this.setState({ dismissed: true }); + } - if (!user || !user.is_identity_verified) { - actionsLeft++; - } + const { user } = this.props; + let actionsLeft = 0; + if (!user || !user.has_verified_email) { + actionsLeft++; + } - this.setState({ actionsLeft }); + if (!user || !user.is_identity_verified) { + actionsLeft++; + } + + this.setState({ actionsLeft }); + }); + } + + onDismissPressed = () => { + AsyncStorage.setItem(RewardSummary.itemKey, 'true'); + this.setState({ dismissed: true }); + this.props.notify({ + message: 'You can always claim your rewards from the Rewards page.', + displayType: ['toast'] + }); } render() { const { fetching, navigation, unclaimedRewardAmount, user } = this.props; - if ((user && user.is_reward_approved) || this.state.actionsLeft === 0 || unclaimedRewardAmount === 0) { + if (this.state.dismissed || + (user && user.is_reward_approved) || + this.state.actionsLeft === 0 || + unclaimedRewardAmount === 0) { return null; } @@ -37,6 +59,7 @@ class RewardSummary extends React.Component { You have {unclaimedRewardAmount} LBC in unclaimed rewards. You have {this.state.actionsLeft} action{this.state.actionsLeft === 1 ? '' : 's'} left to claim your first reward. Tap here to continue. +