fixed crush issue for points screen

This commit is contained in:
u-e 2019-06-12 22:34:11 +03:00
parent 03c17ad03b
commit a0f3d076c3
4 changed files with 24 additions and 13 deletions

View File

@ -44,7 +44,7 @@ const WalletLineItem = ({
</View> </View>
)} )}
<View> <View>
{text && ( {!!text && (
<View> <View>
<Text <Text
style={[ style={[

View File

@ -1,6 +1,7 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Alert } from 'react-native'; import { Alert } from 'react-native';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import get from 'lodash/get';
// Services and Actions // Services and Actions
import { getUser, getUserPoints, claim } from '../../../providers/esteem/ePoint'; import { getUser, getUserPoints, claim } from '../../../providers/esteem/ePoint';
@ -61,9 +62,9 @@ class PointsContainer extends Component {
_groomUserActivities = userActivities => _groomUserActivities = userActivities =>
userActivities.map(item => ({ userActivities.map(item => ({
...item, ...item,
icon: POINTS[item.type].icon, icon: get(POINTS[get(item, 'type')], 'icon'),
iconType: POINTS[item.type].iconType, iconType: get(POINTS[get(item, 'type')], 'iconType'),
textKey: POINTS[item.type].textKey, textKey: get(POINTS[get(item, 'type')], 'textKey'),
})); }));
_fetchuserPointActivities = async username => { _fetchuserPointActivities = async username => {

View File

@ -1,9 +1,8 @@
/* eslint-disable no-nested-ternary */
import React, { Component, Fragment } from 'react'; import React, { Component, Fragment } from 'react';
import { Text, View, FlatList, ScrollView, RefreshControl, TouchableOpacity } from 'react-native'; import { Text, View, FlatList, ScrollView, RefreshControl, TouchableOpacity } from 'react-native';
import { injectIntl } from 'react-intl'; import { injectIntl } from 'react-intl';
import { Popover, PopoverController } from 'react-native-modal-popover'; import { Popover, PopoverController } from 'react-native-modal-popover';
import { get, size } from 'lodash'; import { get } from 'lodash';
// Components // Components
import { LineBreak, WalletLineItem, ListPlaceHolder } from '../../basicUIElements'; import { LineBreak, WalletLineItem, ListPlaceHolder } from '../../basicUIElements';
@ -48,6 +47,19 @@ class PointsView extends Component {
); );
}; };
_getTranslation = id => {
const { intl } = this.props;
let translation;
try {
translation = intl.formatMessage({ id });
} catch (error) {
translation = '';
}
return translation;
};
_renderLoading = () => { _renderLoading = () => {
const { isLoading, intl } = this.props; const { isLoading, intl } = this.props;
@ -58,7 +70,7 @@ class PointsView extends Component {
}; };
render() { render() {
const { claimPoints, intl, isClaiming, userActivities, userPoints } = this.props; const { claimPoints, isClaiming, userActivities, userPoints } = this.props;
return ( return (
<Fragment> <Fragment>
@ -113,7 +125,7 @@ class PointsView extends Component {
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<Text style={styles.subText}> <Text style={styles.subText}>
{intl.formatMessage({ id: get(POINTS[get(item, 'type')], 'nameKey') })} {this._getTranslation(get(POINTS[get(item, 'type')], 'nameKey'))}
</Text> </Text>
<Popover <Popover
backgroundStyle={styles.overlay} backgroundStyle={styles.overlay}
@ -129,9 +141,7 @@ class PointsView extends Component {
> >
<View style={styles.popoverWrapper}> <View style={styles.popoverWrapper}>
<Text style={styles.popoverText}> <Text style={styles.popoverText}>
{intl.formatMessage({ {this._getTranslation(get(POINTS[get(item, 'type')], 'descriptionKey'))}
id: get(POINTS[get(item, 'type')], 'descriptionKey'),
})}
</Text> </Text>
</View> </View>
</Popover> </Popover>
@ -152,7 +162,7 @@ class PointsView extends Component {
renderItem={({ item, index }) => ( renderItem={({ item, index }) => (
<WalletLineItem <WalletLineItem
index={index + 1} index={index + 1}
text={intl.formatMessage({ id: get(item, 'textKey') })} text={this._getTranslation(get(item, 'textKey'))}
description={getTimeFromNow(get(item, 'created'))} description={getTimeFromNow(get(item, 'created'))}
isCircleIcon isCircleIcon
isThin isThin

View File

@ -41,7 +41,7 @@
"checkin_extra": "Bonus", "checkin_extra": "Bonus",
"delegation": "Delegation", "delegation": "Delegation",
"delegation_title": "Delegation reward", "delegation_title": "Delegation reward",
"delegation_desc": "You can earn 1 point per day for every 100sp", "delegation_desc": "You can earn 1 point per day for each 100sp delegation",
"post_title": "Points for post", "post_title": "Points for post",
"comment_title": "Points for comment", "comment_title": "Points for comment",
"vote_title": "Points for vote", "vote_title": "Points for vote",