2022-01-18 15:04:40 +00:00
|
|
|
import { dequal } from 'dequal';
|
2018-12-21 10:55:35 +00:00
|
|
|
import React, { Component } from 'react';
|
2018-10-31 18:40:08 +00:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2022-03-25 20:05:49 +00:00
|
|
|
import { IApplicationState, TUserStatus } from '../../definitions';
|
2021-04-07 18:31:25 +00:00
|
|
|
import { withDimensions } from '../../dimensions';
|
|
|
|
import I18n from '../../i18n';
|
2022-01-18 15:04:40 +00:00
|
|
|
import RoomHeader from './RoomHeader';
|
2018-10-31 18:40:08 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
interface IRoomHeaderContainerProps {
|
|
|
|
title: string;
|
|
|
|
subtitle: string;
|
|
|
|
type: string;
|
|
|
|
prid: string;
|
|
|
|
tmid: string;
|
|
|
|
teamMain: boolean;
|
2022-01-17 16:10:39 +00:00
|
|
|
usersTyping: [];
|
2022-03-25 20:05:49 +00:00
|
|
|
status: TUserStatus;
|
2021-09-13 20:41:05 +00:00
|
|
|
statusText: string;
|
|
|
|
connecting: boolean;
|
|
|
|
connected: boolean;
|
|
|
|
roomUserId: string;
|
|
|
|
widthOffset: number;
|
|
|
|
onPress(): void;
|
|
|
|
width: number;
|
|
|
|
height: number;
|
|
|
|
parentTitle: string;
|
|
|
|
isGroupChat: boolean;
|
|
|
|
testID: string;
|
|
|
|
}
|
2018-10-31 18:40:08 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
class RoomHeaderContainer extends Component<IRoomHeaderContainerProps, any> {
|
|
|
|
shouldComponentUpdate(nextProps: IRoomHeaderContainerProps) {
|
|
|
|
const { type, title, subtitle, status, statusText, connecting, connected, onPress, usersTyping, width, height, teamMain } =
|
|
|
|
this.props;
|
2018-12-21 10:55:35 +00:00
|
|
|
if (nextProps.type !== type) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (nextProps.title !== title) {
|
|
|
|
return true;
|
|
|
|
}
|
2020-03-30 20:19:01 +00:00
|
|
|
if (nextProps.subtitle !== subtitle) {
|
|
|
|
return true;
|
|
|
|
}
|
2018-12-21 10:55:35 +00:00
|
|
|
if (nextProps.status !== status) {
|
|
|
|
return true;
|
|
|
|
}
|
2020-03-30 20:19:01 +00:00
|
|
|
if (nextProps.statusText !== statusText) {
|
|
|
|
return true;
|
|
|
|
}
|
2019-04-30 19:31:51 +00:00
|
|
|
if (nextProps.connecting !== connecting) {
|
|
|
|
return true;
|
|
|
|
}
|
2020-07-06 20:56:28 +00:00
|
|
|
if (nextProps.connected !== connected) {
|
|
|
|
return true;
|
|
|
|
}
|
2020-06-17 17:35:58 +00:00
|
|
|
if (nextProps.width !== width) {
|
2018-12-21 10:55:35 +00:00
|
|
|
return true;
|
|
|
|
}
|
2020-06-17 17:35:58 +00:00
|
|
|
if (nextProps.height !== height) {
|
2018-12-21 10:55:35 +00:00
|
|
|
return true;
|
|
|
|
}
|
2021-02-26 16:01:45 +00:00
|
|
|
if (!dequal(nextProps.usersTyping, usersTyping)) {
|
2019-04-29 16:03:52 +00:00
|
|
|
return true;
|
|
|
|
}
|
2021-04-07 18:31:25 +00:00
|
|
|
if (nextProps.onPress !== onPress) {
|
2019-11-25 20:01:17 +00:00
|
|
|
return true;
|
|
|
|
}
|
[NEW] Convert/Move Channel to Team (#3164)
* Added Create Team
* Added actionTypes, actions, ENG strings for Teams and updated NewMessageView
* Added createTeam sagas, createTeam reducer, new Team string and update CreateChannelView
* Remove unnecessary actionTypes, reducers and sagas, e2e tests and navigation to team view
* Minor tweaks
* Show TeamChannelsView only if joined the team
* Minor tweak
* Added AddChannelTeamView
* Added permissions, translations strings for teams, deleteTeamRoom and addTeamRooms, AddExistingChannelView, updated CreateChannelView, TeamChannelsView
* Refactor touch component and update removeRoom and deleteRoom methods
* Minor tweaks
* Minor tweaks for removing channels and addExistingChannelView
* Added missing events and fixed channels list
* Minor tweaks for refactored touch component
* Added SelectListView and logic for leaving team
* Added addTeamMember and removeTeamMember
* Minor tweak
* Added deleteTeam function
* Minor tweak
* Minor tweaks
* Remove unnecesary changes, update TeamChannelsView, AddExistingChannelView, AddChannelTeamView, createChannel, goRoom and Touchable
* Remove unnecesary prop
* Add screens to ModalStack, events, autoJoin, update createChannel, addRoomsToTeam and Touchable
* Minor tweak
* Update loadMessagesForRoom.js
* Updated schema, tag component, touch, AddChannelTeamView, AddExistingChannelView, ActionSheet Item
* Fix unnecessary changes
* Add i18n, update createChannel, AddExistingChannelTeamView, AddChannelTeamView, RightButton and TeamChannelsView
* Updated styles, added tag story
* Minor tweak
* Minor tweaks
* Auto-join tweak
* Minor tweaks
* Minor tweak on search
* Minor refactor to ListItem, add SelectListView to ModalStack, update handleLeaveTeam
* Minor tweaks
* Update SelectListView
* Update handleLeaveTeam, remove unnecessary method, add story
* Minor tweak
* Minor visual tweaks
* Update SelectListView.js
* Update index.js
* Update RoomMembersView
* Updated SelectListView, RoomActionsView, leaveTeam method and string translations
* Update SelectListVIew
* Minor tweak
* Update SelectListView
* Minor tweak
* Minor tweaks
* Fix for List.Item subtitles being pushed down by title's flex
* Minor tweaks
* Update RoomActionsView
* Use showConfirmationAlert and showErrorAlert
* Remove addTeamMember, update removeTeamMember
* Update Alert
* Minor tweaks
* Minor tweaks
* Minor tweak
* Update showActionSheet on RoomMembersView
* Remove team main from query and move code around
* Fetch roles
* Update RoomMembersView and SelectListView
* Update rocketchat.js
* Updated leaveTeam and handleRemoveFromTeam
* Fix validation
* Remove unnecessary function
* Update RoomActionsView
* Update en.json
* updated deleteTeam function and permissions
* Added showConfirmationAlert
* Added string translations for teams
* Fix permission
* Added moveChannelToTeam and convertToTeam functionality
* Fix SelectListView RadioButton
* Fix moveToTeam
* Added searchBar to SelectListVIew
* Update RoomView , SelectListVIew and string translation for error
Co-authored-by: Diego Mello <diegolmello@gmail.com>
2021-06-02 13:44:19 +00:00
|
|
|
if (nextProps.teamMain !== teamMain) {
|
|
|
|
return true;
|
|
|
|
}
|
2018-12-21 10:55:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-10-31 18:40:08 +00:00
|
|
|
render() {
|
|
|
|
const {
|
2021-03-31 17:47:17 +00:00
|
|
|
title,
|
|
|
|
subtitle: subtitleProp,
|
|
|
|
type,
|
2021-04-07 18:31:25 +00:00
|
|
|
teamMain,
|
2021-03-31 17:47:17 +00:00
|
|
|
prid,
|
|
|
|
tmid,
|
|
|
|
status = 'offline',
|
|
|
|
statusText,
|
|
|
|
connecting,
|
|
|
|
connected,
|
|
|
|
usersTyping,
|
2021-04-07 18:31:25 +00:00
|
|
|
onPress,
|
2021-03-31 17:47:17 +00:00
|
|
|
width,
|
|
|
|
height,
|
|
|
|
parentTitle,
|
2021-04-07 18:31:25 +00:00
|
|
|
isGroupChat,
|
|
|
|
testID
|
2018-10-31 18:40:08 +00:00
|
|
|
} = this.props;
|
|
|
|
|
2020-07-06 20:56:28 +00:00
|
|
|
let subtitle;
|
|
|
|
if (connecting) {
|
|
|
|
subtitle = I18n.t('Connecting');
|
|
|
|
} else if (!connected) {
|
|
|
|
subtitle = I18n.t('Waiting_for_network');
|
|
|
|
} else {
|
|
|
|
subtitle = subtitleProp;
|
|
|
|
}
|
|
|
|
|
2018-10-31 18:40:08 +00:00
|
|
|
return (
|
2021-04-07 18:31:25 +00:00
|
|
|
<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}
|
2020-03-30 20:19:01 +00:00
|
|
|
subtitle={type === 'd' ? statusText : subtitle}
|
2019-04-08 12:35:28 +00:00
|
|
|
type={type}
|
2021-04-07 18:31:25 +00:00
|
|
|
teamMain={teamMain}
|
2019-04-08 12:35:28 +00:00
|
|
|
status={status}
|
2020-06-17 17:35:58 +00:00
|
|
|
width={width}
|
|
|
|
height={height}
|
2019-04-08 12:35:28 +00:00
|
|
|
usersTyping={usersTyping}
|
2020-10-30 17:35:07 +00:00
|
|
|
parentTitle={parentTitle}
|
2021-03-31 17:47:17 +00:00
|
|
|
isGroupChat={isGroupChat}
|
2021-04-07 18:31:25 +00:00
|
|
|
testID={testID}
|
|
|
|
onPress={onPress}
|
2019-04-08 12:35:28 +00:00
|
|
|
/>
|
2018-10-31 18:40:08 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 17:01:03 +00:00
|
|
|
|
2022-01-18 15:04:40 +00:00
|
|
|
const mapStateToProps = (state: IApplicationState, ownProps: any) => {
|
|
|
|
let statusText = '';
|
2020-05-08 17:36:10 +00:00
|
|
|
let status = 'offline';
|
2021-09-13 20:41:05 +00:00
|
|
|
const { roomUserId, type, visitor = {}, tmid } = ownProps;
|
2020-05-08 17:36:10 +00:00
|
|
|
|
|
|
|
if (state.meteor.connected) {
|
2020-10-30 17:35:07 +00:00
|
|
|
if ((type === 'd' || (tmid && roomUserId)) && state.activeUsers[roomUserId]) {
|
2020-05-08 17:36:10 +00:00
|
|
|
({ status, statusText } = state.activeUsers[roomUserId]);
|
|
|
|
} else if (type === 'l' && visitor?.status) {
|
|
|
|
({ status } = visitor);
|
2019-08-07 13:51:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2020-07-06 20:56:28 +00:00
|
|
|
connecting: state.meteor.connecting || state.server.loading,
|
|
|
|
connected: state.meteor.connected,
|
2019-09-16 20:26:32 +00:00
|
|
|
usersTyping: state.usersTyping,
|
2022-03-25 20:05:49 +00:00
|
|
|
status: status as TUserStatus,
|
2020-03-30 20:19:01 +00:00
|
|
|
statusText
|
2019-08-07 13:51:34 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-04-07 18:31:25 +00:00
|
|
|
export default connect(mapStateToProps)(withDimensions(RoomHeaderContainer));
|