nehanced notification items && fixed transfer title issues

This commit is contained in:
ue 2019-10-20 18:08:40 +03:00
parent 06ca41c965
commit 08d61c28c5
54 changed files with 111 additions and 133 deletions

View File

@ -1,7 +1,7 @@
import React, { PureComponent } from 'react';
import React, { useState, useEffect } from 'react';
import { View, Text, Image, TouchableHighlight } from 'react-native';
import { injectIntl } from 'react-intl';
// Constants
import { useIntl } from 'react-intl';
import get from 'lodash/get';
// Components
import { UserAvatar } from '../../userAvatar';
@ -9,64 +9,41 @@ import { UserAvatar } from '../../userAvatar';
// Styles
import styles from './notificationLineStyles';
class NotificationLineView extends PureComponent {
/* Props
* ------------------------------------------------
* @prop { type } name - Description....
*/
const NotificationLineView = ({ notification, handleOnPressNotification }) => {
const [isRead, setIsRead] = useState(notification.read);
const intl = useIntl();
let _title;
let titleExtra = '';
constructor(props) {
super(props);
this.state = {
isRead: props.notification.read,
};
}
// Component Life Cycles
UNSAFE_componentWillReceiveProps(nextProps) {
const { notification } = this.props;
if (notification.read !== nextProps.notification.read) {
this.setState({ isRead: nextProps.notification.read });
}
}
useEffect(() => {
setIsRead(notification.read);
}, [notification]);
// Component Functions
_handleOnNotificationPress = () => {
const { handleOnPressNotification, notification } = this.props;
const { isRead } = this.state;
if (!isRead) this.setState({ isRead: true });
const _handleOnNotificationPress = () => {
if (!isRead) {
setIsRead(true);
}
handleOnPressNotification(notification);
};
render() {
const {
notification,
intl: { formatMessage },
} = this.props;
const { isRead } = this.state;
let _title = formatMessage({
id: `notification.${notification.type}`,
});
if (notification.weight) {
if (notification.type === 'transfer') {
titleExtra = notification.amount;
} else if (notification.weight) {
const _percent = `${parseFloat((notification.weight / 100).toFixed(2))}% `;
if (notification.weight < 0) {
_title = formatMessage({
id: 'notification.unvote',
});
titleExtra = _percent;
}
_title = _percent + _title;
}
_title = `${titleExtra} ${intl.formatMessage({
id: `notification.${notification.type}`,
})}`;
return (
<TouchableHighlight onPress={() => this._handleOnNotificationPress()}>
<TouchableHighlight onPress={_handleOnNotificationPress}>
<View
key={Math.random()}
key={`${get(notification, 'id')}${_title}`}
style={[styles.notificationWrapper, !isRead && styles.isNewNotification]}
>
<UserAvatar
@ -84,7 +61,8 @@ class NotificationLineView extends PureComponent {
</Text>
)}
</View>
{notification.image && (
{get(notification, 'image', null) && (
<Image
style={styles.image}
source={{ uri: notification.image }}
@ -94,7 +72,6 @@ class NotificationLineView extends PureComponent {
</View>
</TouchableHighlight>
);
}
}
};
export default injectIntl(NotificationLineView);
export default NotificationLineView;

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "আপনাকে অননুসরণ করেছে",
"ignore": "আপনাকে উপেক্ষা করেছে",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,8 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"comingsoon": "Feature is coming soon!",
"transfer": "transferred",
"notification": "Notifications",
"leaderboard": "Leaderboard",
"epoint": "Points",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "dejó de seguirte",
"ignore": "te ignoró",
"reblog": "reblogueó tu publicación",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notificaciones",
"leaderboard": "Tabla de posiciones",

View File

@ -19,7 +19,7 @@
"unfollow": "lopetti seuraamisesi",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unlaistida þuk",
"ignore": "ignored you",
"reblog": "aftrablaugida þein waurd",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "te prestao/la pratiti",
"ignore": "te ignorira",
"reblog": "je podijelio tvoju objavu",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Obavijesti",
"leaderboard": "Rang lista",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "non ti segue più",
"ignore": "ti ha ignorato",
"reblog": "ha ripostato il tuo post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifiche",
"leaderboard": "Classifica",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "ontvolgt je",
"ignore": "heeft je genegeerd",
"reblog": "deelde je bericht",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notificaties",
"leaderboard": "Scorebord",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "unfollowed you",
"ignore": "ignored you",
"reblog": "reblogged your post",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Notifications",
"leaderboard": "Leaderboard",

View File

@ -19,7 +19,7 @@
"unfollow": "ko ba o lo mo",
"ignore": "ti ko eti ikun",
"reblog": "ti se eda oro re",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "Awon Akiyesi",
"leaderboard": "Ate asiwaju",

View File

@ -19,7 +19,7 @@
"unfollow": "取消关注了您",
"ignore": "忽视了您",
"reblog": "转发了您的帖子",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "通知",
"leaderboard": "排行榜",

View File

@ -19,7 +19,7 @@
"unfollow": "取消關注了您",
"ignore": "忽略了您",
"reblog": "轉發了您的帖子",
"transfer": "transfered steem",
"transfer": "transferred",
"comingsoon": "Feature is coming soon!",
"notification": "通知",
"leaderboard": "排行榜",

View File

@ -1,7 +1,7 @@
import React, { Component } from 'react';
import { Alert } from 'react-native';
import { connect } from 'react-redux';
import { get, some, isEmpty } from 'lodash';
import get from 'lodash/get';
import { injectIntl } from 'react-intl';
// Actions and Services
@ -118,7 +118,9 @@ class NotificationContainer extends Component {
const { username, dispatch, intl, isConnected } = this.props;
const { notifications } = this.state;
if (!isConnected) return;
if (!isConnected) {
return;
}
this.setState({ isNotificationRefreshing: true });