2019-04-18 20:57:35 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { View, Text } from 'react-native';
|
|
|
|
|
|
|
|
import styles from './styles';
|
|
|
|
|
|
|
|
const UnreadBadge = React.memo(({ unread, userMentions, type }) => {
|
|
|
|
if (!unread || unread <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (unread >= 1000) {
|
|
|
|
unread = '999+';
|
|
|
|
}
|
|
|
|
const mentioned = userMentions > 0 && type !== 'd';
|
|
|
|
|
|
|
|
return (
|
2019-04-24 18:36:29 +00:00
|
|
|
<View style={[styles.unreadNumberContainer, mentioned && styles.unreadMentionedContainer]}>
|
|
|
|
<Text style={[styles.unreadText, mentioned && styles.unreadMentionedText]}>{ unread }</Text>
|
2019-04-18 20:57:35 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
UnreadBadge.propTypes = {
|
|
|
|
unread: PropTypes.number,
|
|
|
|
userMentions: PropTypes.number,
|
|
|
|
type: PropTypes.string
|
|
|
|
};
|
|
|
|
|
|
|
|
export default UnreadBadge;
|