2021-09-13 20:41:05 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { View } from 'react-native';
|
|
|
|
|
|
|
|
import styles from './styles';
|
|
|
|
import Wrapper from './Wrapper';
|
2022-04-20 21:37:54 +00:00
|
|
|
import UnreadBadge from '../UnreadBadge';
|
2021-09-13 20:41:05 +00:00
|
|
|
import TypeIcon from './TypeIcon';
|
|
|
|
import LastMessage from './LastMessage';
|
|
|
|
import Title from './Title';
|
|
|
|
import UpdatedAt from './UpdatedAt';
|
|
|
|
import Touchable from './Touchable';
|
|
|
|
import Tag from './Tag';
|
|
|
|
import I18n from '../../i18n';
|
2022-04-07 14:10:03 +00:00
|
|
|
import { DisplayMode } from '../../lib/constants';
|
2022-04-20 21:37:54 +00:00
|
|
|
import { IRoomItemProps } from './interfaces';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
|
|
|
const RoomItem = ({
|
|
|
|
rid,
|
|
|
|
type,
|
|
|
|
prid,
|
|
|
|
name,
|
|
|
|
avatar,
|
|
|
|
username,
|
|
|
|
showLastMessage,
|
|
|
|
status = 'offline',
|
|
|
|
useRealName,
|
|
|
|
isFocused,
|
|
|
|
isGroupChat,
|
|
|
|
isRead,
|
|
|
|
date,
|
|
|
|
accessibilityLabel,
|
|
|
|
favorite,
|
|
|
|
lastMessage,
|
|
|
|
alert,
|
|
|
|
hideUnreadStatus,
|
|
|
|
unread,
|
|
|
|
userMentions,
|
|
|
|
groupMentions,
|
|
|
|
tunread,
|
|
|
|
tunreadUser,
|
|
|
|
tunreadGroup,
|
|
|
|
testID,
|
|
|
|
swipeEnabled = true,
|
|
|
|
onPress,
|
|
|
|
onLongPress,
|
|
|
|
toggleFav,
|
|
|
|
toggleRead,
|
|
|
|
hideChannel,
|
|
|
|
teamMain,
|
2021-10-06 20:30:10 +00:00
|
|
|
autoJoin,
|
|
|
|
showAvatar,
|
2022-04-15 02:27:36 +00:00
|
|
|
displayMode,
|
2022-06-13 13:24:54 +00:00
|
|
|
sourceType,
|
2022-12-13 18:53:04 +00:00
|
|
|
hideMentionStatus,
|
|
|
|
touchableRef
|
2022-04-20 21:37:54 +00:00
|
|
|
}: IRoomItemProps) => (
|
2021-09-13 20:41:05 +00:00
|
|
|
<Touchable
|
2022-12-13 18:53:04 +00:00
|
|
|
ref={touchableRef}
|
2021-09-13 20:41:05 +00:00
|
|
|
onPress={onPress}
|
|
|
|
onLongPress={onLongPress}
|
|
|
|
favorite={favorite}
|
|
|
|
toggleFav={toggleFav}
|
|
|
|
isRead={isRead}
|
|
|
|
rid={rid}
|
|
|
|
toggleRead={toggleRead}
|
|
|
|
hideChannel={hideChannel}
|
|
|
|
testID={testID}
|
|
|
|
type={type}
|
2022-06-27 18:23:43 +00:00
|
|
|
isFocused={!!isFocused}
|
2021-10-06 20:30:10 +00:00
|
|
|
swipeEnabled={swipeEnabled}
|
2022-08-08 21:02:08 +00:00
|
|
|
displayMode={displayMode}
|
|
|
|
>
|
2021-10-06 20:30:10 +00:00
|
|
|
<Wrapper
|
|
|
|
accessibilityLabel={accessibilityLabel}
|
|
|
|
avatar={avatar}
|
|
|
|
type={type}
|
|
|
|
rid={rid}
|
|
|
|
prid={prid}
|
|
|
|
status={status}
|
|
|
|
isGroupChat={isGroupChat}
|
|
|
|
teamMain={teamMain}
|
|
|
|
displayMode={displayMode}
|
|
|
|
showAvatar={showAvatar}
|
2022-06-27 18:23:43 +00:00
|
|
|
showLastMessage={!!showLastMessage}
|
2022-08-08 21:02:08 +00:00
|
|
|
sourceType={sourceType}
|
|
|
|
>
|
2022-01-11 14:47:23 +00:00
|
|
|
{showLastMessage && displayMode === DisplayMode.Expanded ? (
|
2021-09-13 20:41:05 +00:00
|
|
|
<>
|
|
|
|
<View style={styles.titleContainer}>
|
2021-10-06 20:30:10 +00:00
|
|
|
{showAvatar ? (
|
2022-04-15 02:27:36 +00:00
|
|
|
<TypeIcon
|
|
|
|
type={type}
|
|
|
|
prid={prid}
|
|
|
|
status={status}
|
|
|
|
isGroupChat={isGroupChat}
|
|
|
|
teamMain={teamMain}
|
|
|
|
sourceType={sourceType}
|
|
|
|
/>
|
2021-10-06 20:30:10 +00:00
|
|
|
) : null}
|
2022-06-27 18:23:43 +00:00
|
|
|
<Title name={name} hideUnreadStatus={hideUnreadStatus} alert={alert} />
|
2021-09-13 20:41:05 +00:00
|
|
|
{autoJoin ? <Tag testID='auto-join-tag' name={I18n.t('Auto-join')} /> : null}
|
2022-06-27 18:23:43 +00:00
|
|
|
<UpdatedAt date={date} hideUnreadStatus={hideUnreadStatus} alert={alert} />
|
2021-09-13 20:41:05 +00:00
|
|
|
</View>
|
|
|
|
<View style={styles.row}>
|
|
|
|
<LastMessage
|
|
|
|
lastMessage={lastMessage}
|
|
|
|
type={type}
|
|
|
|
showLastMessage={showLastMessage}
|
2022-06-27 18:23:43 +00:00
|
|
|
username={username || ''}
|
2021-09-13 20:41:05 +00:00
|
|
|
alert={alert && !hideUnreadStatus}
|
|
|
|
useRealName={useRealName}
|
|
|
|
/>
|
|
|
|
<UnreadBadge
|
|
|
|
unread={unread}
|
|
|
|
userMentions={userMentions}
|
|
|
|
groupMentions={groupMentions}
|
|
|
|
tunread={tunread}
|
|
|
|
tunreadUser={tunreadUser}
|
|
|
|
tunreadGroup={tunreadGroup}
|
2022-06-13 13:24:54 +00:00
|
|
|
hideMentionStatus={hideMentionStatus}
|
|
|
|
hideUnreadStatus={hideUnreadStatus}
|
2021-09-13 20:41:05 +00:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<View style={[styles.titleContainer, styles.flex]}>
|
2021-10-06 20:30:10 +00:00
|
|
|
<TypeIcon
|
|
|
|
type={type}
|
|
|
|
prid={prid}
|
|
|
|
status={status}
|
|
|
|
isGroupChat={isGroupChat}
|
|
|
|
teamMain={teamMain}
|
|
|
|
size={22}
|
|
|
|
style={{ marginRight: 8 }}
|
2022-04-15 02:27:36 +00:00
|
|
|
sourceType={sourceType}
|
2021-10-06 20:30:10 +00:00
|
|
|
/>
|
2022-06-27 18:23:43 +00:00
|
|
|
<Title name={name} hideUnreadStatus={hideUnreadStatus} alert={alert} />
|
2021-09-13 20:41:05 +00:00
|
|
|
{autoJoin ? <Tag name={I18n.t('Auto-join')} /> : null}
|
2021-10-06 20:30:10 +00:00
|
|
|
<View style={styles.wrapUpdatedAndBadge}>
|
2022-06-27 18:23:43 +00:00
|
|
|
<UpdatedAt date={date} hideUnreadStatus={hideUnreadStatus} alert={alert} />
|
2021-10-06 20:30:10 +00:00
|
|
|
<UnreadBadge
|
|
|
|
unread={unread}
|
|
|
|
userMentions={userMentions}
|
|
|
|
groupMentions={groupMentions}
|
|
|
|
tunread={tunread}
|
|
|
|
tunreadUser={tunreadUser}
|
|
|
|
tunreadGroup={tunreadGroup}
|
2022-06-13 13:24:54 +00:00
|
|
|
hideMentionStatus={hideMentionStatus}
|
|
|
|
hideUnreadStatus={hideUnreadStatus}
|
2021-10-06 20:30:10 +00:00
|
|
|
/>
|
|
|
|
</View>
|
2021-09-13 20:41:05 +00:00
|
|
|
</View>
|
|
|
|
)}
|
|
|
|
</Wrapper>
|
|
|
|
</Touchable>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default RoomItem;
|