-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathReportActionItemThread.js
86 lines (74 loc) · 3.75 KB
/
ReportActionItemThread.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import PropTypes from 'prop-types';
import React from 'react';
import {Text, View} from 'react-native';
import avatarPropTypes from '@components/avatarPropTypes';
import MultipleAvatars from '@components/MultipleAvatars';
import PressableWithSecondaryInteraction from '@components/PressableWithSecondaryInteraction';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import withWindowDimensions, {windowDimensionsPropTypes} from '@components/withWindowDimensions';
import compose from '@libs/compose';
import useThemeStyles from '@styles/useThemeStyles';
import * as Report from '@userActions/Report';
import CONST from '@src/CONST';
const propTypes = {
/** List of participant icons for the thread */
icons: PropTypes.arrayOf(avatarPropTypes).isRequired,
/** Number of comments under the thread */
numberOfReplies: PropTypes.number.isRequired,
/** Time of the most recent reply */
mostRecentReply: PropTypes.string.isRequired,
/** ID of child thread report */
childReportID: PropTypes.string.isRequired,
/** Whether the thread item / message is being hovered */
isHovered: PropTypes.bool.isRequired,
/** The function that should be called when the thread is LongPressed or right-clicked */
onSecondaryInteraction: PropTypes.func.isRequired,
...withLocalizePropTypes,
...windowDimensionsPropTypes,
};
function ReportActionItemThread(props) {
const styles = useThemeStyles();
const numberOfRepliesText = props.numberOfReplies > CONST.MAX_THREAD_REPLIES_PREVIEW ? `${CONST.MAX_THREAD_REPLIES_PREVIEW}+` : `${props.numberOfReplies}`;
const replyText = props.numberOfReplies === 1 ? props.translate('threads.reply') : props.translate('threads.replies');
const timeStamp = props.datetimeToCalendarTime(props.mostRecentReply, false);
return (
<View style={[styles.chatItemMessage]}>
<PressableWithSecondaryInteraction
onPress={() => {
Report.navigateToAndOpenChildReport(props.childReportID);
}}
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
accessibilityLabel={`${props.numberOfReplies} ${replyText}`}
onSecondaryInteraction={props.onSecondaryInteraction}
>
<View style={[styles.flexRow, styles.alignItemsCenter, styles.mt2]}>
<MultipleAvatars
size={CONST.AVATAR_SIZE.SMALL}
icons={props.icons}
shouldStackHorizontally
isHovered={props.isHovered}
isInReportAction
/>
<View style={[styles.flex1, styles.flexRow, styles.lh140Percent, styles.alignItemsEnd]}>
<Text
style={[styles.link, styles.ml2, styles.h4, styles.noWrap, styles.userSelectNone]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
{`${numberOfRepliesText} ${replyText}`}
</Text>
<Text
numberOfLines={1}
style={[styles.ml2, styles.textMicroSupporting, styles.flex1, styles.userSelectNone]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
{timeStamp}
</Text>
</View>
</View>
</PressableWithSecondaryInteraction>
</View>
);
}
ReportActionItemThread.propTypes = propTypes;
ReportActionItemThread.displayName = 'ReportActionItemThread';
export default compose(withLocalize, withWindowDimensions)(ReportActionItemThread);