vn-verdnaturachat/app/containers/RoomHeader/index.tsx

149 lines
3.2 KiB
TypeScript
Raw Normal View History

import { dequal } from 'dequal';
import React, { Component } from 'react';
2018-10-31 18:40:08 +00:00
import { connect } from 'react-redux';
import { IApplicationState, TUserStatus } from '../../definitions';
import { withDimensions } 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;
usersTyping: [];
status: TUserStatus;
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
class RoomHeaderContainer extends Component<IRoomHeaderContainerProps, any> {
shouldComponentUpdate(nextProps: IRoomHeaderContainerProps) {
const { type, title, subtitle, status, statusText, connecting, connected, onPress, usersTyping, width, height, teamMain } =
this.props;
if (nextProps.type !== type) {
return true;
}
if (nextProps.title !== title) {
return true;
}
if (nextProps.subtitle !== subtitle) {
return true;
}
if (nextProps.status !== status) {
return true;
}
if (nextProps.statusText !== statusText) {
return true;
}
if (nextProps.connecting !== connecting) {
return true;
}
if (nextProps.connected !== connected) {
return true;
}
if (nextProps.width !== width) {
return true;
}
if (nextProps.height !== height) {
return true;
}
if (!dequal(nextProps.usersTyping, usersTyping)) {
2019-04-29 16:03:52 +00:00
return true;
}
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;
}
return false;
}
2018-10-31 18:40:08 +00:00
render() {
const {
title,
subtitle: subtitleProp,
type,
teamMain,
prid,
tmid,
status = 'offline',
statusText,
connecting,
connected,
usersTyping,
onPress,
width,
height,
parentTitle,
isGroupChat,
testID
2018-10-31 18:40:08 +00:00
} = this.props;
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 (
<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}
2019-04-08 12:35:28 +00:00
/>
2018-10-31 18:40:08 +00:00
);
}
}
2019-04-17 17:01:03 +00:00
const mapStateToProps = (state: IApplicationState, ownProps: any) => {
let statusText = '';
[NEW] Livechat (#2004) * [WIP][NEW] Livechat info/actions * [IMPROVEMENT] RoomActionsView * [NEW] Visitor Navigation * [NEW] Get Department REST * [FIX] Borders * [IMPROVEMENT] Refactor RoomInfo View * [FIX] Error while navigate from mention -> roomInfo * [NEW] Livechat Fields * [NEW] Close Livechat * [WIP] Forward livechat * [NEW] Return inquiry * [WIP] Comment when close livechat * [WIP] Improve roomInfo * [IMPROVEMENT] Forward room * [FIX] Department picker * [FIX] Picker without results * [FIX] Superfluous argument * [FIX] Check permissions on RoomActionsView * [FIX] Livechat permissions * [WIP] Show edit to livechat * [I18N] Add pt-br translations * [WIP] Livechat Info * [IMPROVEMENT] Livechat info * [WIP] Livechat Edit * [WIP] Livechat edit * [WIP] Livechat Edit * [WIP] Livechat edit scroll * [FIX] Edit customFields * [FIX] Clean livechat customField * [FIX] Visitor Navigation * [NEW] Next input logic LivechatEdit * [FIX] Add livechat data to subscription * [FIX] Revert change * [NEW] Livechat user Status * [WIP] Livechat tags * [NEW] Edit livechat tags * [FIX] Prevent some crashes * [FIX] Forward * [FIX] Return Livechat error * [FIX] Prevent livechat info crash * [IMPROVEMENT] Use input style on forward chat * OnboardingSeparator -> OrSeparator * [FIX] Go to next input * [NEW] Added some icons * [NEW] Livechat close * [NEW] Forward Room Action * [FIX] Livechat edit style * [FIX] Change status logic * [CHORE] Remove unnecessary logic * [CHORE] Remove unnecessary code * [CHORE] Remove unecessary case * [FIX] Superfluous argument * [IMPROVEMENT] Submit livechat edit * [CHORE] Remove textInput type * [FIX] Livechat edit * [FIX] Livechat Edit * [FIX] Use same effect * [IMPROVEMENT] Tags input * [FIX] Add empty tag * Fix minor issues * Fix typo * insert livechat room data to our room object * review * add method calls server version Co-authored-by: Diego Mello <diegolmello@gmail.com>
2020-05-08 17:36:10 +00:00
let status = 'offline';
const { roomUserId, type, visitor = {}, tmid } = ownProps;
[NEW] Livechat (#2004) * [WIP][NEW] Livechat info/actions * [IMPROVEMENT] RoomActionsView * [NEW] Visitor Navigation * [NEW] Get Department REST * [FIX] Borders * [IMPROVEMENT] Refactor RoomInfo View * [FIX] Error while navigate from mention -> roomInfo * [NEW] Livechat Fields * [NEW] Close Livechat * [WIP] Forward livechat * [NEW] Return inquiry * [WIP] Comment when close livechat * [WIP] Improve roomInfo * [IMPROVEMENT] Forward room * [FIX] Department picker * [FIX] Picker without results * [FIX] Superfluous argument * [FIX] Check permissions on RoomActionsView * [FIX] Livechat permissions * [WIP] Show edit to livechat * [I18N] Add pt-br translations * [WIP] Livechat Info * [IMPROVEMENT] Livechat info * [WIP] Livechat Edit * [WIP] Livechat edit * [WIP] Livechat Edit * [WIP] Livechat edit scroll * [FIX] Edit customFields * [FIX] Clean livechat customField * [FIX] Visitor Navigation * [NEW] Next input logic LivechatEdit * [FIX] Add livechat data to subscription * [FIX] Revert change * [NEW] Livechat user Status * [WIP] Livechat tags * [NEW] Edit livechat tags * [FIX] Prevent some crashes * [FIX] Forward * [FIX] Return Livechat error * [FIX] Prevent livechat info crash * [IMPROVEMENT] Use input style on forward chat * OnboardingSeparator -> OrSeparator * [FIX] Go to next input * [NEW] Added some icons * [NEW] Livechat close * [NEW] Forward Room Action * [FIX] Livechat edit style * [FIX] Change status logic * [CHORE] Remove unnecessary logic * [CHORE] Remove unnecessary code * [CHORE] Remove unecessary case * [FIX] Superfluous argument * [IMPROVEMENT] Submit livechat edit * [CHORE] Remove textInput type * [FIX] Livechat edit * [FIX] Livechat Edit * [FIX] Use same effect * [IMPROVEMENT] Tags input * [FIX] Add empty tag * Fix minor issues * Fix typo * insert livechat room data to our room object * review * add method calls server version Co-authored-by: Diego Mello <diegolmello@gmail.com>
2020-05-08 17:36:10 +00:00
if (state.meteor.connected) {
[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
if ((type === 'd' || (tmid && roomUserId)) && state.activeUsers[roomUserId]) {
[NEW] Livechat (#2004) * [WIP][NEW] Livechat info/actions * [IMPROVEMENT] RoomActionsView * [NEW] Visitor Navigation * [NEW] Get Department REST * [FIX] Borders * [IMPROVEMENT] Refactor RoomInfo View * [FIX] Error while navigate from mention -> roomInfo * [NEW] Livechat Fields * [NEW] Close Livechat * [WIP] Forward livechat * [NEW] Return inquiry * [WIP] Comment when close livechat * [WIP] Improve roomInfo * [IMPROVEMENT] Forward room * [FIX] Department picker * [FIX] Picker without results * [FIX] Superfluous argument * [FIX] Check permissions on RoomActionsView * [FIX] Livechat permissions * [WIP] Show edit to livechat * [I18N] Add pt-br translations * [WIP] Livechat Info * [IMPROVEMENT] Livechat info * [WIP] Livechat Edit * [WIP] Livechat edit * [WIP] Livechat Edit * [WIP] Livechat edit scroll * [FIX] Edit customFields * [FIX] Clean livechat customField * [FIX] Visitor Navigation * [NEW] Next input logic LivechatEdit * [FIX] Add livechat data to subscription * [FIX] Revert change * [NEW] Livechat user Status * [WIP] Livechat tags * [NEW] Edit livechat tags * [FIX] Prevent some crashes * [FIX] Forward * [FIX] Return Livechat error * [FIX] Prevent livechat info crash * [IMPROVEMENT] Use input style on forward chat * OnboardingSeparator -> OrSeparator * [FIX] Go to next input * [NEW] Added some icons * [NEW] Livechat close * [NEW] Forward Room Action * [FIX] Livechat edit style * [FIX] Change status logic * [CHORE] Remove unnecessary logic * [CHORE] Remove unnecessary code * [CHORE] Remove unecessary case * [FIX] Superfluous argument * [IMPROVEMENT] Submit livechat edit * [CHORE] Remove textInput type * [FIX] Livechat edit * [FIX] Livechat Edit * [FIX] Use same effect * [IMPROVEMENT] Tags input * [FIX] Add empty tag * Fix minor issues * Fix typo * insert livechat room data to our room object * review * add method calls server version Co-authored-by: Diego Mello <diegolmello@gmail.com>
2020-05-08 17:36:10 +00:00
({ status, statusText } = state.activeUsers[roomUserId]);
} else if (type === 'l' && visitor?.status) {
({ status } = visitor);
}
}
return {
connecting: state.meteor.connecting || state.server.loading,
connected: state.meteor.connected,
[CHORE] Migrate to Watermelon (#1171) * Install * Create subscriptions * Subscription observing and sorting * Saving last message * Stash * Stash * stash * Stash * Rooms list listing :) * Animated set state * Search working * Fix load rooms on login * stash db class * set active db with path * Remove db on logout * stash * Created updateMessages * Inserting/updating threads * Persisting thread messages * Removed unused list * Loading messages from watermelon * Debounce updates and rerender message * optional fields * Fix realm conflict issues * Fix some render issues * stash * List mount * stash * fix message id * Fix tmsg * - Save subscription.rid as id on watermelon and _id as _id - Send room as param to room view * Throttle room updates * stash * comment removeClippedSubviews * Fetch thread name * try/catch updateMessages * Show loading while RoomView.init is still running * stash * Fix updateMessages * Threads * Delete message * Permalink * Pin * Star * Report * MessageActions refactor * Edit message * Reply message * Add reaction * Auto translate * Fix connection issues * Mark message as error if something happened on the call * Error actions * get custom emoji * Always run console.log when __DEV__ * Try to create serversDB * Don't call updateMessages. Execute that entire logic for one message id instead. * Refactor update messages * ServersDB User [Realm -> Watermelon] * Fix models * Custom emojis * Custom emojis on emoji picker * Frequently used emojis * Fix add reaction on message * stash * Fix * Read messages * Fix thread * Fetch thread header * Follow/unfollow thread * Fix thread * Upload file * Thread tweak * Realm -> Watermelon [Share Extension] * Add RoomsUpdatedAt to Servers Table * Settings * Settings * Fix logout * SendFileMessage ServersDB * ServersDB on serverDropdown * Remove serversDB from Realm * Load thread messages * Delete message * Improve getSettings * Improve * Remove subscription * Remove update * Update room via socket * Small refactor * Fix logout and improve migration * Refactor updateMessages * Improve migration * Remove unnecessary update * Revert remove runAfterInteractions * Fix serverDropdown * Fix merge * Init room actions Watermelon * Room actions Watermelon * Remove realm on room members * Room swipe -> Watermelon * Fix hideChannel * Get roles watermelon * Get permissions watermelon * Users typing + memory db * Auto translate watermelon * New Message View * Selected Users View * try/catch * Get Slash Commands watermelon * Slash Commands message box * Custom emojis message box * Get rooms message box * Room info view * Room info edit * Save active users * Small refactor * Message Actions * hasPermission await * last hasPermission fix * Active users on redux * Add user roles * Users typing on redux and remove memory db * Fix saga delay * Fix few issues * Fix slash commands preview * Draft message * Add muted * Unread count watermelon * Remove realm * Fiz RoomItem rerenders * Remove realm config * Rerender status update on RoomItem * Refactor RoomsListView * Fix load missed messages * Fix room update * Message refactor * Fixing lint * removeClippedSubviews on iOS only * Added few interaction managers * Fix few rerenders * Fix RoomItem status typo * Fix RoomView.SCU * Fix broadcast * Fix user status on RoomActionsView * Fix RocketChat.hasPermission * Fix database inconsistencies * Fix few update issues * Add rxjs and remove with observables * Fix tests * Remove subscriptions * Fix RoomsListView SCU * Change database structure and set all schemas to 1 * Fix RoomsListView search * Fixed errors, removed rerenders and added animation * Fixed a few errors * Fix lint * Fix issues caught by LGTM * fix ios build * Fix load unjoined channel messages * Log on database path on startup * Fix join channel * Remove react-native-realm-path * Set user status on login.user reducer * Fix status not rendering on RoomsListView * Fix few reducers * Fix users going offline * Never use "watermelon" term directly. Replaced by "database" * Fix custom emoji * Creating room from app must update roomUpdatedAt * Log subscribeRoom start * Fix room subscribe right after creating a DM * Refactor is read only on messages actions * Fix typo * Fix typo * Review * Fix schema * Fix muted & freq emoji & unpin & unstar * Remove throttleTime to room info & fix reset on edit room * Fix openServerDropdown spec & Fix unarchive * Fix MessageAction * Refactor RoomInfoEditView * Remove unnecessary condition * Remove unnecessary condition * Remove unnecessary condition * Remove get database * Rename Command.js to SlashCommand.js * Create sanitizer util * Fix indentation * Create subscription.t index * Refactor queries on RoomsListView * Create subscription.name index * Fix getPermissions * Fix indentation * Add missing await * Fix rocketchat.hasPermission * Unnecessary change * Star, pin e delete message refactored * Refactor customEmojis reducer * Remove code * Remove logs * Remove throttle * Call this.init on foreground focus on RoomView * Bump servers schema migration * Always mark message as sent after a success * Fetch only messages needed on updateMessages * Just leave a comment for now * Fetch only subscriptions returned by fetch * Set room param on RoomView header in find room * Update kotlin * Fix auto translate constructor * Fix few setState on constructor * Fix empty room image blinking while mounting * Improve fetch/persist execution for custom emojis, permissions and settings * Query only user tapped on RoomMembersView * Fix typo on canOpenRoom
2019-09-16 20:26:32 +00:00
usersTyping: state.usersTyping,
status: status as TUserStatus,
statusText
};
};
export default connect(mapStateToProps)(withDimensions(RoomHeaderContainer));