2020-10-30 17:35:07 +00:00
|
|
|
import React, { Component } from 'react';
|
2019-04-17 17:01:03 +00:00
|
|
|
import { connect } from 'react-redux';
|
2021-02-26 16:01:45 +00:00
|
|
|
import { dequal } from 'dequal';
|
2022-03-02 14:18:01 +00:00
|
|
|
import { Observable, Subscription } from 'rxjs';
|
2022-06-09 14:42:12 +00:00
|
|
|
import { Dispatch } from 'redux';
|
2022-03-02 14:18:01 +00:00
|
|
|
import { StackNavigationProp } from '@react-navigation/stack';
|
2019-04-17 17:01:03 +00:00
|
|
|
|
2022-07-15 20:06:27 +00:00
|
|
|
import { ILivechatTag } from '../../definitions/ILivechatTag';
|
2021-04-07 18:31:25 +00:00
|
|
|
import * as HeaderButton from '../../containers/HeaderButton';
|
|
|
|
import database from '../../lib/database';
|
|
|
|
import { getUserSelector } from '../../selectors/login';
|
2022-06-06 14:17:51 +00:00
|
|
|
import { events, logEvent } from '../../lib/methods/helpers/log';
|
|
|
|
import { isTeamRoom } from '../../lib/methods/helpers/room';
|
2022-03-02 14:18:01 +00:00
|
|
|
import { IApplicationState, SubscriptionType, TMessageModel, TSubscriptionModel } from '../../definitions';
|
|
|
|
import { ChatsStackParamList } from '../../stacks/types';
|
2022-08-08 18:38:01 +00:00
|
|
|
import { TActionSheetOptionsItem } from '../../containers/ActionSheet';
|
2022-06-09 14:42:12 +00:00
|
|
|
import i18n from '../../i18n';
|
|
|
|
import { showConfirmationAlert, showErrorAlert } from '../../lib/methods/helpers';
|
|
|
|
import { onHoldLivechat, returnLivechat } from '../../lib/services/restApi';
|
2022-06-27 19:03:24 +00:00
|
|
|
import { closeLivechat as closeLivechatService } from '../../lib/methods/helpers/closeLivechat';
|
2022-07-15 20:06:27 +00:00
|
|
|
import { Services } from '../../lib/services';
|
|
|
|
import { ILivechatDepartment } from '../../definitions/ILivechatDepartment';
|
2022-03-02 14:18:01 +00:00
|
|
|
|
2022-08-08 18:38:01 +00:00
|
|
|
interface IRightButtonsProps {
|
2022-03-02 14:18:01 +00:00
|
|
|
userId?: string;
|
|
|
|
threadsEnabled: boolean;
|
2022-08-08 18:38:01 +00:00
|
|
|
rid?: string;
|
2022-03-02 14:18:01 +00:00
|
|
|
t: string;
|
|
|
|
tmid?: string;
|
|
|
|
teamId?: string;
|
|
|
|
isMasterDetail: boolean;
|
|
|
|
toggleFollowThread: Function;
|
|
|
|
joined: boolean;
|
2022-06-09 14:42:12 +00:00
|
|
|
status?: string;
|
|
|
|
dispatch: Dispatch;
|
2022-03-02 14:18:01 +00:00
|
|
|
encrypted?: boolean;
|
|
|
|
navigation: StackNavigationProp<ChatsStackParamList, 'RoomView'>;
|
2022-06-09 14:42:12 +00:00
|
|
|
omnichannelPermissions: {
|
|
|
|
canForwardGuest: boolean;
|
|
|
|
canReturnQueue: boolean;
|
|
|
|
canPlaceLivechatOnHold: boolean;
|
|
|
|
};
|
2022-06-27 19:03:24 +00:00
|
|
|
livechatRequestComment: boolean;
|
2022-08-08 18:38:01 +00:00
|
|
|
showActionSheet: Function;
|
2022-07-15 20:06:27 +00:00
|
|
|
departmentId?: string;
|
2022-03-02 14:18:01 +00:00
|
|
|
}
|
2019-04-17 17:01:03 +00:00
|
|
|
|
2022-03-02 14:18:01 +00:00
|
|
|
interface IRigthButtonsState {
|
|
|
|
isFollowingThread: boolean;
|
|
|
|
tunread: string[];
|
|
|
|
tunreadUser: string[];
|
|
|
|
tunreadGroup: string[];
|
|
|
|
}
|
|
|
|
|
|
|
|
class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsState> {
|
|
|
|
private threadSubscription?: Subscription;
|
|
|
|
private subSubscription?: Subscription;
|
2019-04-17 17:01:03 +00:00
|
|
|
|
2022-03-02 14:18:01 +00:00
|
|
|
constructor(props: IRightButtonsProps) {
|
2019-04-17 17:01:03 +00:00
|
|
|
super(props);
|
|
|
|
this.state = {
|
2020-10-30 17:35:07 +00:00
|
|
|
isFollowingThread: true,
|
|
|
|
tunread: [],
|
|
|
|
tunreadUser: [],
|
|
|
|
tunreadGroup: []
|
2019-04-17 17:01:03 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
async componentDidMount() {
|
2020-10-30 17:35:07 +00:00
|
|
|
const { tmid, rid } = this.props;
|
|
|
|
const db = database.active;
|
2019-09-16 20:26:32 +00:00
|
|
|
if (tmid) {
|
2019-11-18 22:09:54 +00:00
|
|
|
try {
|
2021-02-26 16:25:51 +00:00
|
|
|
const threadRecord = await db.get('messages').find(tmid);
|
2020-10-30 17:35:07 +00:00
|
|
|
this.observeThread(threadRecord);
|
2019-11-18 22:09:54 +00:00
|
|
|
} catch (e) {
|
2021-09-13 20:41:05 +00:00
|
|
|
console.log("Can't find message to observe.");
|
2019-11-18 22:09:54 +00:00
|
|
|
}
|
2019-05-20 20:43:50 +00:00
|
|
|
}
|
2020-10-30 17:35:07 +00:00
|
|
|
if (rid) {
|
|
|
|
try {
|
2021-02-26 16:25:51 +00:00
|
|
|
const subCollection = db.get('subscriptions');
|
2020-10-30 17:35:07 +00:00
|
|
|
const subRecord = await subCollection.find(rid);
|
|
|
|
this.observeSubscription(subRecord);
|
|
|
|
} catch (e) {
|
2021-09-13 20:41:05 +00:00
|
|
|
console.log("Can't find subscription to observe.");
|
2020-10-30 17:35:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-02 14:18:01 +00:00
|
|
|
shouldComponentUpdate(nextProps: IRightButtonsProps, nextState: IRigthButtonsState) {
|
2021-09-13 20:41:05 +00:00
|
|
|
const { isFollowingThread, tunread, tunreadUser, tunreadGroup } = this.state;
|
2022-06-09 14:42:12 +00:00
|
|
|
const { teamId, status, joined, omnichannelPermissions } = this.props;
|
[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.teamId !== teamId) {
|
|
|
|
return true;
|
|
|
|
}
|
2022-06-09 14:42:12 +00:00
|
|
|
if (nextProps.status !== status) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (nextProps.joined !== joined) {
|
|
|
|
return true;
|
|
|
|
}
|
2020-10-30 17:35:07 +00:00
|
|
|
if (nextState.isFollowingThread !== isFollowingThread) {
|
|
|
|
return true;
|
|
|
|
}
|
2022-06-09 14:42:12 +00:00
|
|
|
if (!dequal(nextProps.omnichannelPermissions, omnichannelPermissions)) {
|
|
|
|
return true;
|
|
|
|
}
|
2021-02-26 16:01:45 +00:00
|
|
|
if (!dequal(nextState.tunread, tunread)) {
|
2020-10-30 17:35:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
2021-02-26 16:01:45 +00:00
|
|
|
if (!dequal(nextState.tunreadUser, tunreadUser)) {
|
2020-10-30 17:35:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
2021-02-26 16:01:45 +00:00
|
|
|
if (!dequal(nextState.tunreadGroup, tunreadGroup)) {
|
2020-10-30 17:35:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
2021-02-23 17:44:01 +00:00
|
|
|
return false;
|
2019-05-15 19:33:30 +00:00
|
|
|
}
|
|
|
|
|
2019-05-03 13:33:38 +00:00
|
|
|
componentWillUnmount() {
|
2019-09-16 20:26:32 +00:00
|
|
|
if (this.threadSubscription && this.threadSubscription.unsubscribe) {
|
|
|
|
this.threadSubscription.unsubscribe();
|
2019-05-03 13:33:38 +00:00
|
|
|
}
|
2020-10-30 17:35:07 +00:00
|
|
|
if (this.subSubscription && this.subSubscription.unsubscribe) {
|
|
|
|
this.subSubscription.unsubscribe();
|
|
|
|
}
|
2019-05-03 13:33:38 +00:00
|
|
|
}
|
|
|
|
|
2022-03-02 14:18:01 +00:00
|
|
|
observeThread = (threadRecord: TMessageModel) => {
|
|
|
|
const threadObservable: Observable<TMessageModel> = threadRecord.observe();
|
2021-09-13 20:41:05 +00:00
|
|
|
this.threadSubscription = threadObservable.subscribe(thread => this.updateThread(thread));
|
|
|
|
};
|
2019-11-18 22:09:54 +00:00
|
|
|
|
2022-03-02 14:18:01 +00:00
|
|
|
updateThread = (thread: TMessageModel) => {
|
2019-04-17 17:01:03 +00:00
|
|
|
const { userId } = this.props;
|
|
|
|
this.setState({
|
2022-03-02 14:18:01 +00:00
|
|
|
isFollowingThread: (thread.replies && !!thread.replies.find(t => t === userId)) ?? false
|
2019-04-17 17:01:03 +00:00
|
|
|
});
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-04-17 17:01:03 +00:00
|
|
|
|
2022-03-02 14:18:01 +00:00
|
|
|
observeSubscription = (subRecord: TSubscriptionModel) => {
|
2020-10-30 17:35:07 +00:00
|
|
|
const subObservable = subRecord.observe();
|
2021-09-13 20:41:05 +00:00
|
|
|
this.subSubscription = subObservable.subscribe(sub => {
|
|
|
|
this.updateSubscription(sub);
|
|
|
|
});
|
|
|
|
};
|
2020-10-30 17:35:07 +00:00
|
|
|
|
2022-03-02 14:18:01 +00:00
|
|
|
updateSubscription = (sub: TSubscriptionModel) => {
|
2020-10-30 17:35:07 +00:00
|
|
|
this.setState({
|
2022-03-02 14:18:01 +00:00
|
|
|
tunread: sub?.tunread ?? [],
|
|
|
|
tunreadUser: sub?.tunreadUser ?? [],
|
|
|
|
tunreadGroup: sub?.tunreadGroup ?? []
|
2020-10-30 17:35:07 +00:00
|
|
|
});
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2020-10-30 17:35:07 +00:00
|
|
|
|
2021-04-07 18:31:25 +00:00
|
|
|
goTeamChannels = () => {
|
|
|
|
logEvent(events.ROOM_GO_TEAM_CHANNELS);
|
2022-05-09 13:21:09 +00:00
|
|
|
const { navigation, isMasterDetail, teamId, joined } = this.props;
|
2022-03-02 14:18:01 +00:00
|
|
|
if (!teamId) {
|
|
|
|
return;
|
|
|
|
}
|
2021-04-07 18:31:25 +00:00
|
|
|
if (isMasterDetail) {
|
2022-03-02 14:18:01 +00:00
|
|
|
// @ts-ignore TODO: find a way to make this work
|
2021-04-07 18:31:25 +00:00
|
|
|
navigation.navigate('ModalStackNavigator', {
|
|
|
|
screen: 'TeamChannelsView',
|
2022-05-09 13:21:09 +00:00
|
|
|
params: { teamId, joined }
|
2021-04-07 18:31:25 +00:00
|
|
|
});
|
|
|
|
} else {
|
2022-05-09 13:21:09 +00:00
|
|
|
navigation.navigate('TeamChannelsView', { teamId, joined });
|
2021-04-07 18:31:25 +00:00
|
|
|
}
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2021-04-07 18:31:25 +00:00
|
|
|
|
2019-04-17 17:01:03 +00:00
|
|
|
goThreadsView = () => {
|
2020-08-05 13:15:56 +00:00
|
|
|
logEvent(events.ROOM_GO_THREADS);
|
2021-09-13 20:41:05 +00:00
|
|
|
const { rid, t, navigation, isMasterDetail } = this.props;
|
2022-03-02 14:18:01 +00:00
|
|
|
if (!rid) {
|
|
|
|
return;
|
|
|
|
}
|
2020-06-15 14:00:46 +00:00
|
|
|
if (isMasterDetail) {
|
2022-03-02 14:18:01 +00:00
|
|
|
// @ts-ignore TODO: find a way to make this work
|
2020-06-15 14:00:46 +00:00
|
|
|
navigation.navigate('ModalStackNavigator', { screen: 'ThreadMessagesView', params: { rid, t } });
|
|
|
|
} else {
|
2022-03-02 14:18:01 +00:00
|
|
|
navigation.navigate('ThreadMessagesView', { rid, t: t as SubscriptionType });
|
2020-06-15 14:00:46 +00:00
|
|
|
}
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-04-17 17:01:03 +00:00
|
|
|
|
2022-06-09 14:42:12 +00:00
|
|
|
returnLivechat = () => {
|
|
|
|
const { rid } = this.props;
|
2022-08-08 18:38:01 +00:00
|
|
|
if (rid) {
|
|
|
|
showConfirmationAlert({
|
|
|
|
message: i18n.t('Would_you_like_to_return_the_inquiry'),
|
|
|
|
confirmationText: i18n.t('Yes'),
|
|
|
|
onPress: async () => {
|
|
|
|
try {
|
|
|
|
await returnLivechat(rid);
|
|
|
|
} catch (e: any) {
|
|
|
|
showErrorAlert(e.reason, i18n.t('Oops'));
|
|
|
|
}
|
2022-06-09 14:42:12 +00:00
|
|
|
}
|
2022-08-08 18:38:01 +00:00
|
|
|
});
|
|
|
|
}
|
2022-06-09 14:42:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
placeOnHoldLivechat = () => {
|
|
|
|
const { navigation, rid } = this.props;
|
2022-08-08 18:38:01 +00:00
|
|
|
if (rid) {
|
|
|
|
showConfirmationAlert({
|
|
|
|
title: i18n.t('Are_you_sure_question_mark'),
|
|
|
|
message: i18n.t('Would_like_to_place_on_hold'),
|
|
|
|
confirmationText: i18n.t('Yes'),
|
|
|
|
onPress: async () => {
|
|
|
|
try {
|
|
|
|
await onHoldLivechat(rid);
|
|
|
|
navigation.navigate('RoomsListView');
|
|
|
|
} catch (e: any) {
|
|
|
|
showErrorAlert(e.data?.error, i18n.t('Oops'));
|
|
|
|
}
|
2022-06-09 14:42:12 +00:00
|
|
|
}
|
2022-08-08 18:38:01 +00:00
|
|
|
});
|
|
|
|
}
|
2022-06-09 14:42:12 +00:00
|
|
|
};
|
|
|
|
|
2022-07-15 20:06:27 +00:00
|
|
|
closeLivechat = async () => {
|
|
|
|
const { rid, departmentId } = this.props;
|
|
|
|
const { livechatRequestComment, isMasterDetail, navigation } = this.props;
|
|
|
|
let departmentInfo: ILivechatDepartment | undefined;
|
|
|
|
let tagsList: ILivechatTag[] | undefined;
|
2022-06-27 19:03:24 +00:00
|
|
|
|
2022-07-15 20:06:27 +00:00
|
|
|
if (departmentId) {
|
|
|
|
const result = await Services.getDepartmentInfo(departmentId);
|
|
|
|
if (result.success) {
|
|
|
|
departmentInfo = result.department as ILivechatDepartment;
|
2022-06-27 19:03:24 +00:00
|
|
|
}
|
2022-07-15 20:06:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (departmentInfo?.requestTagBeforeClosingChat) {
|
|
|
|
tagsList = await Services.getTagsList();
|
|
|
|
}
|
|
|
|
|
2022-08-08 18:38:01 +00:00
|
|
|
if (rid) {
|
|
|
|
if (!livechatRequestComment && !departmentInfo?.requestTagBeforeClosingChat) {
|
|
|
|
const comment = i18n.t('Chat_closed_by_agent');
|
|
|
|
return closeLivechatService({ rid, isMasterDetail, comment });
|
|
|
|
}
|
2022-06-27 19:03:24 +00:00
|
|
|
|
2022-08-08 18:38:01 +00:00
|
|
|
if (isMasterDetail) {
|
|
|
|
navigation.navigate('ModalStackNavigator', {
|
|
|
|
screen: 'CloseLivechatView',
|
|
|
|
params: { rid, departmentId, departmentInfo, tagsList }
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
navigation.navigate('CloseLivechatView', { rid, departmentId, departmentInfo, tagsList });
|
|
|
|
}
|
2022-07-15 20:06:27 +00:00
|
|
|
}
|
2022-06-09 14:42:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
showMoreActions = () => {
|
|
|
|
logEvent(events.ROOM_SHOW_MORE_ACTIONS);
|
2022-07-15 20:06:27 +00:00
|
|
|
const { showActionSheet, rid, navigation, omnichannelPermissions, isMasterDetail } = this.props;
|
2022-06-09 14:42:12 +00:00
|
|
|
|
|
|
|
const options = [] as TActionSheetOptionsItem[];
|
|
|
|
if (omnichannelPermissions.canPlaceLivechatOnHold) {
|
|
|
|
options.push({
|
|
|
|
title: i18n.t('Place_chat_on_hold'),
|
|
|
|
icon: 'pause',
|
|
|
|
onPress: () => this.placeOnHoldLivechat()
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (omnichannelPermissions.canForwardGuest) {
|
|
|
|
options.push({
|
|
|
|
title: i18n.t('Forward_Chat'),
|
|
|
|
icon: 'chat-forward',
|
2022-07-15 20:06:27 +00:00
|
|
|
onPress: () => {
|
2022-08-08 18:38:01 +00:00
|
|
|
if (rid) {
|
|
|
|
if (isMasterDetail) {
|
|
|
|
navigation.navigate('ModalStackNavigator', {
|
|
|
|
screen: 'ForwardLivechatView',
|
|
|
|
params: { rid }
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
navigation.navigate('ForwardLivechatView', { rid });
|
|
|
|
}
|
2022-07-15 20:06:27 +00:00
|
|
|
}
|
|
|
|
}
|
2022-06-09 14:42:12 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (omnichannelPermissions.canReturnQueue) {
|
|
|
|
options.push({
|
|
|
|
title: i18n.t('Return_to_waiting_line'),
|
|
|
|
icon: 'move-to-the-queue',
|
|
|
|
onPress: () => this.returnLivechat()
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
options.push({
|
|
|
|
title: i18n.t('Close'),
|
|
|
|
icon: 'chat-close',
|
|
|
|
onPress: () => this.closeLivechat(),
|
|
|
|
danger: true
|
|
|
|
});
|
|
|
|
|
|
|
|
showActionSheet({ options });
|
|
|
|
};
|
|
|
|
|
2020-07-06 20:56:28 +00:00
|
|
|
goSearchView = () => {
|
2020-08-05 13:15:56 +00:00
|
|
|
logEvent(events.ROOM_GO_SEARCH);
|
2021-10-05 13:58:21 +00:00
|
|
|
const { rid, t, navigation, isMasterDetail, encrypted } = this.props;
|
2022-03-02 14:18:01 +00:00
|
|
|
if (!rid) {
|
|
|
|
return;
|
|
|
|
}
|
2020-07-06 20:56:28 +00:00
|
|
|
if (isMasterDetail) {
|
2022-03-02 14:18:01 +00:00
|
|
|
// @ts-ignore TODO: find a way to make this work
|
2021-10-05 13:58:21 +00:00
|
|
|
navigation.navigate('ModalStackNavigator', {
|
|
|
|
screen: 'SearchMessagesView',
|
|
|
|
params: { rid, showCloseModal: true, encrypted }
|
|
|
|
});
|
2020-07-06 20:56:28 +00:00
|
|
|
} else {
|
2022-03-02 14:18:01 +00:00
|
|
|
navigation.navigate('SearchMessagesView', { rid, t: t as SubscriptionType, encrypted });
|
2020-07-06 20:56:28 +00:00
|
|
|
}
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2020-07-06 20:56:28 +00:00
|
|
|
|
2019-05-15 19:33:30 +00:00
|
|
|
toggleFollowThread = () => {
|
2020-08-05 13:15:56 +00:00
|
|
|
logEvent(events.ROOM_TOGGLE_FOLLOW_THREADS);
|
2019-04-17 17:01:03 +00:00
|
|
|
const { isFollowingThread } = this.state;
|
2019-05-15 19:33:30 +00:00
|
|
|
const { toggleFollowThread } = this.props;
|
|
|
|
if (toggleFollowThread) {
|
|
|
|
toggleFollowThread(isFollowingThread);
|
2019-04-17 17:01:03 +00:00
|
|
|
}
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-04-17 17:01:03 +00:00
|
|
|
|
2022-06-09 14:42:12 +00:00
|
|
|
isOmnichannelPreview = () => {
|
|
|
|
const { status } = this.props;
|
|
|
|
return status === 'queued';
|
|
|
|
};
|
|
|
|
|
2019-04-17 17:01:03 +00:00
|
|
|
render() {
|
2021-09-13 20:41:05 +00:00
|
|
|
const { isFollowingThread, tunread, tunreadUser, tunreadGroup } = this.state;
|
|
|
|
const { t, tmid, threadsEnabled, teamId, joined } = this.props;
|
2022-06-09 14:42:12 +00:00
|
|
|
|
2019-04-17 17:01:03 +00:00
|
|
|
if (t === 'l') {
|
2022-06-09 14:42:12 +00:00
|
|
|
if (!this.isOmnichannelPreview()) {
|
|
|
|
return (
|
|
|
|
<HeaderButton.Container>
|
|
|
|
<HeaderButton.Item iconName='kebab' onPress={this.showMoreActions} testID='room-view-header-omnichannel-kebab' />
|
|
|
|
</HeaderButton.Container>
|
|
|
|
);
|
|
|
|
}
|
2019-04-17 17:01:03 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (tmid) {
|
|
|
|
return (
|
2020-10-30 16:15:58 +00:00
|
|
|
<HeaderButton.Container>
|
|
|
|
<HeaderButton.Item
|
2020-07-27 19:53:33 +00:00
|
|
|
iconName={isFollowingThread ? 'notification' : 'notification-disabled'}
|
2019-04-17 17:01:03 +00:00
|
|
|
onPress={this.toggleFollowThread}
|
|
|
|
testID={isFollowingThread ? 'room-view-header-unfollow' : 'room-view-header-follow'}
|
|
|
|
/>
|
2020-10-30 16:15:58 +00:00
|
|
|
</HeaderButton.Container>
|
2019-04-17 17:01:03 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return (
|
2020-10-30 16:15:58 +00:00
|
|
|
<HeaderButton.Container>
|
2021-05-12 19:01:29 +00:00
|
|
|
{isTeamRoom({ teamId, joined }) ? (
|
2021-09-13 20:41:05 +00:00
|
|
|
<HeaderButton.Item iconName='channel-public' onPress={this.goTeamChannels} testID='room-view-header-team-channels' />
|
2021-04-07 18:31:25 +00:00
|
|
|
) : null}
|
2019-04-17 17:01:03 +00:00
|
|
|
{threadsEnabled ? (
|
2020-10-30 16:15:58 +00:00
|
|
|
<HeaderButton.Item
|
2020-06-05 13:28:58 +00:00
|
|
|
iconName='threads'
|
2019-04-17 17:01:03 +00:00
|
|
|
onPress={this.goThreadsView}
|
|
|
|
testID='room-view-header-threads'
|
2021-09-13 20:41:05 +00:00
|
|
|
badge={() => <HeaderButton.Badge tunread={tunread} tunreadUser={tunreadUser} tunreadGroup={tunreadGroup} />}
|
2019-04-17 17:01:03 +00:00
|
|
|
/>
|
|
|
|
) : null}
|
2021-09-13 20:41:05 +00:00
|
|
|
<HeaderButton.Item iconName='search' onPress={this.goSearchView} testID='room-view-search' />
|
2020-10-30 16:15:58 +00:00
|
|
|
</HeaderButton.Container>
|
2019-04-17 17:01:03 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-02 14:18:01 +00:00
|
|
|
const mapStateToProps = (state: IApplicationState) => ({
|
2020-02-11 14:09:14 +00:00
|
|
|
userId: getUserSelector(state).id,
|
2022-03-02 14:18:01 +00:00
|
|
|
threadsEnabled: state.settings.Threads_enabled as boolean,
|
2022-06-27 19:03:24 +00:00
|
|
|
isMasterDetail: state.app.isMasterDetail,
|
|
|
|
livechatRequestComment: state.settings.Livechat_request_comment_when_closing_conversation as boolean
|
2019-08-07 13:51:34 +00:00
|
|
|
});
|
|
|
|
|
2022-08-08 18:38:01 +00:00
|
|
|
export default connect(mapStateToProps)(RightButtonsContainer);
|