display total wallet balance. fix dispatch prop.

This commit is contained in:
Akinwale Ariwodola 2019-03-30 05:06:31 +01:00
parent ee75a6bca6
commit d16a614584
8 changed files with 23 additions and 23 deletions

View file

@ -281,7 +281,7 @@ class AppWithNavigationState extends React.Component {
} }
componentDidUpdate() { componentDidUpdate() {
const { user } = this.props; const { dispatch, user } = this.props;
if (this.state.verifyPending && this.emailVerifyCheckInterval > 0 && user && user.has_verified_email) { if (this.state.verifyPending && this.emailVerifyCheckInterval > 0 && user && user.has_verified_email) {
clearInterval(this.emailVerifyCheckInterval); clearInterval(this.emailVerifyCheckInterval);
AsyncStorage.setItem(Constants.KEY_EMAIL_VERIFY_PENDING, 'false'); AsyncStorage.setItem(Constants.KEY_EMAIL_VERIFY_PENDING, 'false');

View file

@ -1,10 +1,10 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectBalance } from 'lbry-redux'; import { selectTotalBalance } from 'lbry-redux';
import { selectUnclaimedRewardValue } from 'lbryinc';
import FloatingWalletBalance from './view'; import FloatingWalletBalance from './view';
import { doRewardList, selectUnclaimedRewardValue, selectFetchingRewards, selectUser } from 'lbryinc';
const select = state => ({ const select = state => ({
balance: selectBalance(state), balance: selectTotalBalance(state),
unclaimedRewardAmount: selectUnclaimedRewardValue(state), unclaimedRewardAmount: selectUnclaimedRewardValue(state),
}); });

View file

@ -18,6 +18,12 @@ class FloatingWalletBalance extends React.PureComponent<Props> {
return ( return (
<View style={[floatingButtonStyle.view, floatingButtonStyle.bottomRight]}> <View style={[floatingButtonStyle.view, floatingButtonStyle.bottomRight]}>
{unclaimedRewardAmount > 0 &&
<TouchableOpacity style={floatingButtonStyle.pendingContainer}
onPress={() => navigation && navigation.navigate({ routeName: 'Rewards' })} >
<Icon name="award" size={18} style={floatingButtonStyle.rewardIcon} />
<Text style={floatingButtonStyle.text}>{unclaimedRewardAmount}</Text>
</TouchableOpacity>}
<TouchableOpacity style={floatingButtonStyle.container} <TouchableOpacity style={floatingButtonStyle.container}
onPress={() => navigation && navigation.navigate({ routeName: 'WalletStack' })}> onPress={() => navigation && navigation.navigate({ routeName: 'WalletStack' })}>
{isNaN(balance) && <ActivityIndicator size="small" color={Colors.White} />} {isNaN(balance) && <ActivityIndicator size="small" color={Colors.White} />}
@ -25,12 +31,6 @@ class FloatingWalletBalance extends React.PureComponent<Props> {
{(balance || balance === 0) && (formatCredits(parseFloat(balance), 2) + ' LBC')} {(balance || balance === 0) && (formatCredits(parseFloat(balance), 2) + ' LBC')}
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>
{unclaimedRewardAmount > 0 &&
<TouchableOpacity style={floatingButtonStyle.pendingContainer}
onPress={() => navigation && navigation.navigate({ routeName: 'Rewards' })} >
<Icon name="award" size={18} style={floatingButtonStyle.rewardIcon} />
<Text style={floatingButtonStyle.text}>{unclaimedRewardAmount}</Text>
</TouchableOpacity>}
</View> </View>
); );
} }

View file

@ -1,9 +1,9 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectBalance } from 'lbry-redux'; import { selectTotalBalance } from 'lbry-redux';
import WalletBalance from './view'; import WalletBalance from './view';
const select = state => ({ const select = state => ({
balance: selectBalance(state), balance: selectTotalBalance(state),
}); });
export default connect(select, null)(WalletBalance); export default connect(select, null)(WalletBalance);

View file

@ -1,10 +1,10 @@
// @flow // @flow
import React from 'react'; import React from 'react';
import { Image, Text, View } from 'react-native'; import { Image, Text, View } from 'react-native';
import { formatCredits } from 'lbry-redux' import { Lbry, formatCredits } from 'lbry-redux'
import Address from '../address'; import Address from 'component/address';
import Button from '../button'; import Button from 'component/button';
import walletStyle from '../../styles/wallet'; import walletStyle from 'styles/wallet';
type Props = { type Props = {
balance: number, balance: number,

View file

@ -1,5 +1,5 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doBalanceSubscribe, doUpdateBlockHeight, doToast } from 'lbry-redux'; import { doTotalBalanceSubscribe, doUpdateBlockHeight, doToast } from 'lbry-redux';
import { import {
doAuthenticate, doAuthenticate,
doBlackListedOutpointsSubscribe, doBlackListedOutpointsSubscribe,
@ -23,7 +23,7 @@ const select = state => ({
const perform = dispatch => ({ const perform = dispatch => ({
authenticate: (appVersion, os) => dispatch(doAuthenticate(appVersion, os)), authenticate: (appVersion, os) => dispatch(doAuthenticate(appVersion, os)),
balanceSubscribe: () => dispatch(doBalanceSubscribe()), totalBalanceSubscribe: () => dispatch(doTotalBalanceSubscribe()),
blacklistedOutpointsSubscribe: () => dispatch(doBlackListedOutpointsSubscribe()), blacklistedOutpointsSubscribe: () => dispatch(doBlackListedOutpointsSubscribe()),
checkSubscriptionsInit: () => dispatch(doCheckSubscriptionsInit()), checkSubscriptionsInit: () => dispatch(doCheckSubscriptionsInit()),
deleteCompleteBlobs: () => dispatch(doDeleteCompleteBlobs()), deleteCompleteBlobs: () => dispatch(doDeleteCompleteBlobs()),

View file

@ -137,7 +137,7 @@ class SplashScreen extends React.PureComponent {
finishSplashScreen = () => { finishSplashScreen = () => {
const { const {
authenticate, authenticate,
balanceSubscribe, totalBalanceSubscribe,
blacklistedOutpointsSubscribe, blacklistedOutpointsSubscribe,
checkSubscriptionsInit, checkSubscriptionsInit,
updateBlockHeight, updateBlockHeight,
@ -147,7 +147,7 @@ class SplashScreen extends React.PureComponent {
Lbry.resolve({ urls: 'lbry://one' }).then(() => { Lbry.resolve({ urls: 'lbry://one' }).then(() => {
// Leave the splash screen // Leave the splash screen
balanceSubscribe(); totalBalanceSubscribe();
blacklistedOutpointsSubscribe(); blacklistedOutpointsSubscribe();
checkSubscriptionsInit(); checkSubscriptionsInit();
updateBlockHeight(); updateBlockHeight();

View file

@ -30,9 +30,9 @@ const floatingButtonStyle = StyleSheet.create({
pendingContainer: { pendingContainer: {
borderRadius: 24, borderRadius: 24,
padding: 14, padding: 14,
paddingLeft: 70, paddingLeft: 20,
paddingRight: 20, paddingRight: 70,
marginLeft: -60, marginRight: -60,
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
backgroundColor: Colors.BrighterLbryGreen, backgroundColor: Colors.BrighterLbryGreen,