2021-09-13 20:41:05 +00:00
|
|
|
import React, { useContext } from 'react';
|
|
|
|
import { Text, View } from 'react-native';
|
|
|
|
|
|
|
|
import styles from './styles';
|
2022-04-07 14:10:03 +00:00
|
|
|
import { themes } from '../../lib/constants';
|
2021-09-13 20:41:05 +00:00
|
|
|
import MessageContext from './Context';
|
|
|
|
import ThreadDetails from '../ThreadDetails';
|
|
|
|
import I18n from '../../i18n';
|
|
|
|
import { IMessageThread } from './interfaces';
|
2022-04-01 21:52:38 +00:00
|
|
|
import { useTheme } from '../../theme';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
|
|
|
const Thread = React.memo(
|
2022-04-01 21:52:38 +00:00
|
|
|
({ msg, tcount, tlm, isThreadRoom, id }: IMessageThread) => {
|
|
|
|
const { theme } = useTheme();
|
2022-04-11 18:01:43 +00:00
|
|
|
const { threadBadgeColor, toggleFollowThread, user, replies } = useContext(MessageContext);
|
2022-04-01 21:52:38 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
if (!tlm || isThreadRoom || tcount === 0) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<View style={styles.buttonContainer}>
|
|
|
|
<View style={[styles.button, { backgroundColor: themes[theme].tintColor }]} testID={`message-thread-button-${msg}`}>
|
|
|
|
<Text style={[styles.buttonText, { color: themes[theme].buttonText }]}>{I18n.t('Reply')}</Text>
|
|
|
|
</View>
|
|
|
|
<ThreadDetails
|
|
|
|
item={{
|
|
|
|
tcount,
|
|
|
|
replies,
|
|
|
|
id
|
|
|
|
}}
|
|
|
|
user={user}
|
|
|
|
badgeColor={threadBadgeColor}
|
|
|
|
toggleFollowThread={toggleFollowThread}
|
|
|
|
style={styles.threadDetails}
|
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
(prevProps, nextProps) => {
|
|
|
|
if (prevProps.tcount !== nextProps.tcount) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
Thread.displayName = 'MessageThread';
|
|
|
|
|
|
|
|
export default Thread;
|