Rocket.Chat.ReactNative/app/containers/RoomHeader/index.tsx

101 lines
2.6 KiB
TypeScript
Raw Normal View History

import React from 'react';
import { shallowEqual, useSelector } from 'react-redux';
2018-10-31 18:40:08 +00:00
import { IApplicationState, TUserStatus, IOmnichannelSource, IVisitor } from '../../definitions';
import { useDimensions } from '../../dimensions';
import I18n from '../../i18n';
import RoomHeader from './RoomHeader';
2018-10-31 18:40:08 +00:00
interface IRoomHeaderContainerProps {
title?: string;
subtitle?: string;
type: string;
prid?: string;
tmid?: string;
teamMain?: boolean;
roomUserId?: string | null;
onPress: Function;
parentTitle?: string;
isGroupChat?: boolean;
testID?: string;
sourceType?: IOmnichannelSource;
visitor?: IVisitor;
}
2018-10-31 18:40:08 +00:00
const RoomHeaderContainer = React.memo(
({
isGroupChat,
onPress,
parentTitle,
prid,
roomUserId,
subtitle: subtitleProp,
teamMain,
testID,
title,
tmid,
type,
sourceType,
visitor
}: IRoomHeaderContainerProps) => {
let subtitle: string | undefined;
let status: TUserStatus = 'offline';
let statusText: string | undefined;
const { width, height } = useDimensions();
const connecting = useSelector((state: IApplicationState) => state.meteor.connecting || state.server.loading);
const usersTyping = useSelector((state: IApplicationState) => state.usersTyping, shallowEqual);
const connected = useSelector((state: IApplicationState) => state.meteor.connected);
2023-02-14 13:47:56 +00:00
const presenceDisabled = useSelector((state: IApplicationState) => state.settings.Presence_broadcast_disabled);
const activeUser = useSelector(
(state: IApplicationState) => (roomUserId ? state.activeUsers?.[roomUserId] : undefined),
shallowEqual
);
2018-10-31 18:40:08 +00:00
if (connecting) {
subtitle = I18n.t('Connecting');
} else if (!connected) {
subtitle = I18n.t('Waiting_for_network');
} else {
subtitle = subtitleProp;
}
if (connected) {
if ((type === 'd' || (tmid && roomUserId)) && activeUser) {
2023-02-14 13:47:56 +00:00
if (presenceDisabled) {
status = 'disabled';
} else {
const { status: statusActiveUser, statusText: statusTextActiveUser } = activeUser;
status = statusActiveUser;
statusText = statusTextActiveUser;
}
} else if (type === 'l' && visitor?.status) {
const { status: statusVisitor } = visitor;
status = statusVisitor;
}
}
2018-10-31 18:40:08 +00:00
return (
<RoomHeader
2019-04-08 12:35:28 +00:00
prid={prid}
2019-04-17 17:01:03 +00:00
tmid={tmid}
2019-04-08 12:35:28 +00:00
title={title}
subtitle={type === 'd' ? statusText : subtitle}
2019-04-08 12:35:28 +00:00
type={type}
teamMain={teamMain}
2019-04-08 12:35:28 +00:00
status={status}
width={width}
height={height}
2019-04-08 12:35:28 +00:00
usersTyping={usersTyping}
[NEW] Threads (#2567) * [IMPROVEMENT] Mentions layout without background * Fix RoomItem * Fix tests * Smaller messagebox * Messagebox colors tweak * Beginning header buttons refactor * Add HeaderButtons * item with title * Refactor * Remove lib * Refactor * Update snapshot * Send to channel on messagebox * Add tshow * Add showMessageInMainThread to login.user reducer * Filter threads on main channel based on user setting * Send tshow * Add tunread * Move unread colors logic away from UnreadBadge component so it can be used on other components * Export UnreadBadge on index * Add empty test * Refactor * Update tests * Lint * Thread unread user and group on RoomItem * Thread badge working * Started ThreadMessagesView.Item * Fix separator * Reactivity working * Lint * custom emojis aren't necessary * Basic filter layout * Filtering layout * Refactor * apply filter * DropdownItemHeader * default all * few fixes * No data found * Fixes list performance issues * Use locale on date formats * Fixed minor styles * Thread badge * Refactor getBadgeColor * Fix send to channel background color * starting search threads * Fix lint and tests * Bump to 4.12.0 just for testing :) * Search input layout * query * starting threads header * fix unnecessary tlm on tmid messages * Fix thread header * lint * Fix thread header on ShareView * Add e2e tests * Fix subscriptions sort * Update stories and minor fixes * Fix button sizes on Messagebox * Remove comment * Unnecessary conditional * Add showMessageInMainThread to user collection * Fix thread header * Fix thread messages not working on tablet * Reset Messagebox.tshow after sending a message * Allow to send to channel when replying to a thread from main channel * Unnecessary theme prop * Address comments * Remove re-render * Fix scroll indicator bug * Fix style * Minor i18n fix * Fix dropdown height * I18n ptbr * I18n
2020-10-30 17:35:07 +00:00
parentTitle={parentTitle}
isGroupChat={isGroupChat}
testID={testID}
onPress={onPress}
sourceType={sourceType}
2019-04-08 12:35:28 +00:00
/>
2018-10-31 18:40:08 +00:00
);
}
);
export default RoomHeaderContainer;