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-15 02:51:59 +00:00
|
|
|
import UnreadBadge from '../../containers/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-15 02:27:36 +00:00
|
|
|
import { TUserStatus, IOmnichannelSource } from '../../definitions';
|
2022-04-12 16:27:05 +00:00
|
|
|
import { TSupportedThemes } from '../../theme';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
|
|
|
interface IRoomItem {
|
|
|
|
rid: string;
|
|
|
|
type: string;
|
|
|
|
prid: string;
|
|
|
|
name: string;
|
|
|
|
avatar: string;
|
|
|
|
showLastMessage: boolean;
|
|
|
|
username: string;
|
|
|
|
testID: string;
|
|
|
|
width: number;
|
2022-03-25 20:05:49 +00:00
|
|
|
status: TUserStatus;
|
2021-09-13 20:41:05 +00:00
|
|
|
useRealName: boolean;
|
2022-04-12 16:27:05 +00:00
|
|
|
theme: TSupportedThemes;
|
2021-09-13 20:41:05 +00:00
|
|
|
isFocused: boolean;
|
|
|
|
isGroupChat: boolean;
|
|
|
|
isRead: boolean;
|
|
|
|
teamMain: boolean;
|
|
|
|
date: string;
|
|
|
|
accessibilityLabel: string;
|
|
|
|
lastMessage: {
|
|
|
|
u: any;
|
|
|
|
pinned: boolean;
|
|
|
|
t: string;
|
|
|
|
attachments: any;
|
|
|
|
msg: string;
|
|
|
|
e2e: string;
|
|
|
|
};
|
|
|
|
favorite: boolean;
|
|
|
|
alert: boolean;
|
|
|
|
hideUnreadStatus: boolean;
|
|
|
|
unread: number;
|
|
|
|
userMentions: number;
|
|
|
|
groupMentions: number;
|
|
|
|
tunread: [];
|
|
|
|
tunreadUser: [];
|
|
|
|
tunreadGroup: [];
|
|
|
|
swipeEnabled: boolean;
|
|
|
|
toggleFav(): void;
|
|
|
|
toggleRead(): void;
|
|
|
|
onPress(): void;
|
|
|
|
onLongPress(): void;
|
|
|
|
hideChannel(): void;
|
|
|
|
autoJoin: boolean;
|
2021-10-06 20:30:10 +00:00
|
|
|
showAvatar: boolean;
|
|
|
|
displayMode: string;
|
2022-04-15 02:27:36 +00:00
|
|
|
sourceType: IOmnichannelSource;
|
2021-09-13 20:41:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const RoomItem = ({
|
|
|
|
rid,
|
|
|
|
type,
|
|
|
|
prid,
|
|
|
|
name,
|
|
|
|
avatar,
|
|
|
|
width,
|
|
|
|
username,
|
|
|
|
showLastMessage,
|
|
|
|
status = 'offline',
|
|
|
|
useRealName,
|
|
|
|
theme,
|
|
|
|
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,
|
|
|
|
sourceType
|
2021-09-13 20:41:05 +00:00
|
|
|
}: IRoomItem) => (
|
|
|
|
<Touchable
|
|
|
|
onPress={onPress}
|
|
|
|
onLongPress={onLongPress}
|
|
|
|
width={width}
|
|
|
|
favorite={favorite}
|
|
|
|
toggleFav={toggleFav}
|
|
|
|
isRead={isRead}
|
|
|
|
rid={rid}
|
|
|
|
toggleRead={toggleRead}
|
|
|
|
hideChannel={hideChannel}
|
|
|
|
testID={testID}
|
|
|
|
type={type}
|
|
|
|
theme={theme}
|
|
|
|
isFocused={isFocused}
|
2021-10-06 20:30:10 +00:00
|
|
|
swipeEnabled={swipeEnabled}
|
|
|
|
displayMode={displayMode}>
|
|
|
|
<Wrapper
|
|
|
|
accessibilityLabel={accessibilityLabel}
|
|
|
|
avatar={avatar}
|
|
|
|
type={type}
|
|
|
|
theme={theme}
|
|
|
|
rid={rid}
|
|
|
|
prid={prid}
|
|
|
|
status={status}
|
|
|
|
isGroupChat={isGroupChat}
|
|
|
|
teamMain={teamMain}
|
|
|
|
displayMode={displayMode}
|
|
|
|
showAvatar={showAvatar}
|
2022-04-15 02:27:36 +00:00
|
|
|
showLastMessage={showLastMessage}
|
|
|
|
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}
|
2021-09-13 20:41:05 +00:00
|
|
|
<Title name={name} theme={theme} hideUnreadStatus={hideUnreadStatus} alert={alert} />
|
|
|
|
{autoJoin ? <Tag testID='auto-join-tag' name={I18n.t('Auto-join')} /> : null}
|
|
|
|
<UpdatedAt date={date} theme={theme} hideUnreadStatus={hideUnreadStatus} alert={alert} />
|
|
|
|
</View>
|
|
|
|
<View style={styles.row}>
|
|
|
|
<LastMessage
|
|
|
|
lastMessage={lastMessage}
|
|
|
|
type={type}
|
|
|
|
showLastMessage={showLastMessage}
|
|
|
|
username={username}
|
|
|
|
alert={alert && !hideUnreadStatus}
|
|
|
|
useRealName={useRealName}
|
|
|
|
theme={theme}
|
|
|
|
/>
|
|
|
|
<UnreadBadge
|
|
|
|
unread={unread}
|
|
|
|
userMentions={userMentions}
|
|
|
|
groupMentions={groupMentions}
|
|
|
|
tunread={tunread}
|
|
|
|
tunreadUser={tunreadUser}
|
|
|
|
tunreadGroup={tunreadGroup}
|
|
|
|
/>
|
|
|
|
</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
|
|
|
/>
|
2021-09-13 20:41:05 +00:00
|
|
|
<Title name={name} theme={theme} hideUnreadStatus={hideUnreadStatus} alert={alert} />
|
|
|
|
{autoJoin ? <Tag name={I18n.t('Auto-join')} /> : null}
|
2021-10-06 20:30:10 +00:00
|
|
|
<View style={styles.wrapUpdatedAndBadge}>
|
|
|
|
<UpdatedAt date={date} theme={theme} hideUnreadStatus={hideUnreadStatus} alert={alert} />
|
|
|
|
<UnreadBadge
|
|
|
|
unread={unread}
|
|
|
|
userMentions={userMentions}
|
|
|
|
groupMentions={groupMentions}
|
|
|
|
tunread={tunread}
|
|
|
|
tunreadUser={tunreadUser}
|
|
|
|
tunreadGroup={tunreadGroup}
|
|
|
|
/>
|
|
|
|
</View>
|
2021-09-13 20:41:05 +00:00
|
|
|
</View>
|
|
|
|
)}
|
|
|
|
</Wrapper>
|
|
|
|
</Touchable>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default RoomItem;
|