fix: place on-hold permission not updating properly

This commit is contained in:
Gerzon Z 2022-05-04 11:07:18 -04:00
parent c378686a7a
commit 2575d1dc9e
3 changed files with 14 additions and 8 deletions

View File

@ -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;

View File

@ -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<IRightButtonsProps, IRigthButtonsS
confirmationText: i18n.t('Yes'),
onPress: async () => {
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<IRightButtonsProps, IRigthButtonsS
confirmationText: i18n.t('Yes'),
onPress: async () => {
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<IRightButtonsProps, IRigthButtonsS
logEvent(events.ROOM_SHOW_MORE_ACTIONS);
const { showActionSheet, rid, navigation, omnichannelPermissions } = this.props;
const options = [];
const options = [] as TActionSheetOptionsItem[];
if (omnichannelPermissions.canPlaceLivechatOnHold) {
options.push({
title: i18n.t('Place_chat_on_hold'),

View File

@ -143,6 +143,7 @@ const roomAttrsUpdate = [
'teamMain',
'teamId',
'status',
'lastMessage',
'onHold'
] as TRoomUpdate[];
@ -372,7 +373,7 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
}
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<IRoomViewProps, IRoomViewState> {
// 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<IRoomViewProps, IRoomViewState> {
dateSeparator = item.ts;
}
}
console.log({ item });
let content = null;
if (item.t && MESSAGE_TYPE_ANY_LOAD.includes(item.t as MessageTypeLoad)) {
content = (