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>
{text && (
{!!text && (
<View>
<Text
style={[

View File

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

View File

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

View File

@ -41,7 +41,7 @@
"checkin_extra": "Bonus",
"delegation": "Delegation",
"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",
"comment_title": "Points for comment",
"vote_title": "Points for vote",