From 2575d1dc9e4645db2ab704e2cda11976b8aa7b21 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Wed, 4 May 2022 11:07:18 -0400 Subject: [PATCH] fix: place on-hold permission not updating properly --- app/stacks/MasterDetailStack/types.ts | 6 ++++++ app/views/RoomView/RightButtons.tsx | 10 +++++----- app/views/RoomView/index.tsx | 6 +++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/stacks/MasterDetailStack/types.ts b/app/stacks/MasterDetailStack/types.ts index 1edfff731..673a8d8b3 100644 --- a/app/stacks/MasterDetailStack/types.ts +++ b/app/stacks/MasterDetailStack/types.ts @@ -32,6 +32,12 @@ export type ModalStackParamList = { rid: string; t: SubscriptionType; joined: boolean; + omnichannelPermissions: { + canForwardGuest: boolean; + canReturnQueue: boolean; + canViewCannedResponse: boolean; + canPlaceLivechatOnHold: boolean; + }; }; RoomInfoView: { room: ISubscription; diff --git a/app/views/RoomView/RightButtons.tsx b/app/views/RoomView/RightButtons.tsx index 6587679be..11f239148 100644 --- a/app/views/RoomView/RightButtons.tsx +++ b/app/views/RoomView/RightButtons.tsx @@ -12,11 +12,11 @@ import { events, logEvent } from '../../utils/log'; import { isTeamRoom } from '../../utils/room'; import { IApplicationState, SubscriptionType, TMessageModel, TSubscriptionModel } from '../../definitions'; import { ChatsStackParamList } from '../../stacks/types'; -import { TActionSheetOptions, withActionSheet } from '../../containers/ActionSheet'; +import { TActionSheetOptions, TActionSheetOptionsItem, withActionSheet } from '../../containers/ActionSheet'; import i18n from '../../i18n'; import { showConfirmationAlert, showErrorAlert } from '../../utils/info'; import { closeRoom } from '../../actions/room'; -import RocketChat from '../../lib/rocketchat'; +import { onHoldLivechat, returnLivechat } from '../../lib/services/restApi'; interface IRightButtonsProps { userId?: string; @@ -188,7 +188,7 @@ class RightButtonsContainer extends Component { try { - await RocketChat.returnLivechat(rid); + await returnLivechat(rid); } catch (e: any) { showErrorAlert(e.reason, i18n.t('Oops')); } @@ -204,7 +204,7 @@ class RightButtonsContainer extends Component { try { - await RocketChat.onHoldLivechat(rid); + await onHoldLivechat(rid); navigation.navigate('RoomsListView'); } catch (e: any) { showErrorAlert(e.data?.error, i18n.t('Oops')); @@ -222,7 +222,7 @@ class RightButtonsContainer extends Component { } componentDidUpdate(prevProps: IRoomViewProps, prevState: IRoomViewState) { - const { roomUpdate, joined, room } = this.state; + const { roomUpdate, joined } = this.state; const { appState, insets, route } = this.props; if (route?.params?.jumpToMessageId && route?.params?.jumpToMessageId !== prevProps.route?.params?.jumpToMessageId) { @@ -398,7 +399,7 @@ class RoomView extends React.Component { // If it's a livechat room if (this.t === 'l') { if ( - !room.lastMessage?.token || + !roomUpdate?.lastMessage?.token || !dequal(prevState.roomUpdate.visitor, roomUpdate.visitor) || !dequal(prevState.roomUpdate.status, roomUpdate.status) || prevState.joined !== joined @@ -1277,7 +1278,6 @@ class RoomView extends React.Component { dateSeparator = item.ts; } } - console.log({ item }); let content = null; if (item.t && MESSAGE_TYPE_ANY_LOAD.includes(item.t as MessageTypeLoad)) { content = (