2019-10-30 14:14:41 +00:00
|
|
|
import React from 'react';
|
2020-03-03 20:27:38 +00:00
|
|
|
import { FlatList, View } from 'react-native';
|
2019-10-30 14:14:41 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2021-02-26 16:01:45 +00:00
|
|
|
import { dequal } from 'dequal';
|
2019-10-30 14:14:41 +00:00
|
|
|
|
|
|
|
import styles from '../styles';
|
|
|
|
import MentionItem from './MentionItem';
|
2019-12-04 16:39:53 +00:00
|
|
|
import { themes } from '../../../constants/colors';
|
2019-10-30 14:14:41 +00:00
|
|
|
|
2019-12-04 16:39:53 +00:00
|
|
|
const Mentions = React.memo(({ mentions, trackingType, theme }) => {
|
2019-10-30 14:14:41 +00:00
|
|
|
if (!trackingType) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return (
|
2020-03-03 20:27:38 +00:00
|
|
|
<View testID='messagebox-container'>
|
|
|
|
<FlatList
|
|
|
|
style={[styles.mentionList, { backgroundColor: themes[theme].auxiliaryBackground }]}
|
|
|
|
data={mentions}
|
|
|
|
extraData={mentions}
|
|
|
|
renderItem={({ item }) => <MentionItem item={item} trackingType={trackingType} theme={theme} />}
|
|
|
|
keyExtractor={item => item.id || item.username || item.command || item}
|
|
|
|
keyboardShouldPersistTaps='always'
|
|
|
|
/>
|
|
|
|
</View>
|
2019-10-30 14:14:41 +00:00
|
|
|
);
|
|
|
|
}, (prevProps, nextProps) => {
|
2019-12-04 16:39:53 +00:00
|
|
|
if (prevProps.theme !== nextProps.theme) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-10-30 14:14:41 +00:00
|
|
|
if (prevProps.trackingType !== nextProps.trackingType) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-02-26 16:01:45 +00:00
|
|
|
if (!dequal(prevProps.mentions, nextProps.mentions)) {
|
2019-10-30 14:14:41 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
Mentions.propTypes = {
|
|
|
|
mentions: PropTypes.array,
|
2019-12-04 16:39:53 +00:00
|
|
|
trackingType: PropTypes.string,
|
|
|
|
theme: PropTypes.string
|
2019-10-30 14:14:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Mentions;
|