fix: place on-hold permission not updating properly
This commit is contained in:
parent
c378686a7a
commit
2575d1dc9e
|
@ -32,6 +32,12 @@ export type ModalStackParamList = {
|
||||||
rid: string;
|
rid: string;
|
||||||
t: SubscriptionType;
|
t: SubscriptionType;
|
||||||
joined: boolean;
|
joined: boolean;
|
||||||
|
omnichannelPermissions: {
|
||||||
|
canForwardGuest: boolean;
|
||||||
|
canReturnQueue: boolean;
|
||||||
|
canViewCannedResponse: boolean;
|
||||||
|
canPlaceLivechatOnHold: boolean;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
RoomInfoView: {
|
RoomInfoView: {
|
||||||
room: ISubscription;
|
room: ISubscription;
|
||||||
|
|
|
@ -12,11 +12,11 @@ import { events, logEvent } from '../../utils/log';
|
||||||
import { isTeamRoom } from '../../utils/room';
|
import { isTeamRoom } from '../../utils/room';
|
||||||
import { IApplicationState, SubscriptionType, TMessageModel, TSubscriptionModel } from '../../definitions';
|
import { IApplicationState, SubscriptionType, TMessageModel, TSubscriptionModel } from '../../definitions';
|
||||||
import { ChatsStackParamList } from '../../stacks/types';
|
import { ChatsStackParamList } from '../../stacks/types';
|
||||||
import { TActionSheetOptions, withActionSheet } from '../../containers/ActionSheet';
|
import { TActionSheetOptions, TActionSheetOptionsItem, withActionSheet } from '../../containers/ActionSheet';
|
||||||
import i18n from '../../i18n';
|
import i18n from '../../i18n';
|
||||||
import { showConfirmationAlert, showErrorAlert } from '../../utils/info';
|
import { showConfirmationAlert, showErrorAlert } from '../../utils/info';
|
||||||
import { closeRoom } from '../../actions/room';
|
import { closeRoom } from '../../actions/room';
|
||||||
import RocketChat from '../../lib/rocketchat';
|
import { onHoldLivechat, returnLivechat } from '../../lib/services/restApi';
|
||||||
|
|
||||||
interface IRightButtonsProps {
|
interface IRightButtonsProps {
|
||||||
userId?: string;
|
userId?: string;
|
||||||
|
@ -188,7 +188,7 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
|
||||||
confirmationText: i18n.t('Yes'),
|
confirmationText: i18n.t('Yes'),
|
||||||
onPress: async () => {
|
onPress: async () => {
|
||||||
try {
|
try {
|
||||||
await RocketChat.returnLivechat(rid);
|
await returnLivechat(rid);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
showErrorAlert(e.reason, i18n.t('Oops'));
|
showErrorAlert(e.reason, i18n.t('Oops'));
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
|
||||||
confirmationText: i18n.t('Yes'),
|
confirmationText: i18n.t('Yes'),
|
||||||
onPress: async () => {
|
onPress: async () => {
|
||||||
try {
|
try {
|
||||||
await RocketChat.onHoldLivechat(rid);
|
await onHoldLivechat(rid);
|
||||||
navigation.navigate('RoomsListView');
|
navigation.navigate('RoomsListView');
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
showErrorAlert(e.data?.error, i18n.t('Oops'));
|
showErrorAlert(e.data?.error, i18n.t('Oops'));
|
||||||
|
@ -222,7 +222,7 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
|
||||||
logEvent(events.ROOM_SHOW_MORE_ACTIONS);
|
logEvent(events.ROOM_SHOW_MORE_ACTIONS);
|
||||||
const { showActionSheet, rid, navigation, omnichannelPermissions } = this.props;
|
const { showActionSheet, rid, navigation, omnichannelPermissions } = this.props;
|
||||||
|
|
||||||
const options = [];
|
const options = [] as TActionSheetOptionsItem[];
|
||||||
if (omnichannelPermissions.canPlaceLivechatOnHold) {
|
if (omnichannelPermissions.canPlaceLivechatOnHold) {
|
||||||
options.push({
|
options.push({
|
||||||
title: i18n.t('Place_chat_on_hold'),
|
title: i18n.t('Place_chat_on_hold'),
|
||||||
|
|
|
@ -143,6 +143,7 @@ const roomAttrsUpdate = [
|
||||||
'teamMain',
|
'teamMain',
|
||||||
'teamId',
|
'teamId',
|
||||||
'status',
|
'status',
|
||||||
|
'lastMessage',
|
||||||
'onHold'
|
'onHold'
|
||||||
] as TRoomUpdate[];
|
] as TRoomUpdate[];
|
||||||
|
|
||||||
|
@ -372,7 +373,7 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps: IRoomViewProps, prevState: IRoomViewState) {
|
componentDidUpdate(prevProps: IRoomViewProps, prevState: IRoomViewState) {
|
||||||
const { roomUpdate, joined, room } = this.state;
|
const { roomUpdate, joined } = this.state;
|
||||||
const { appState, insets, route } = this.props;
|
const { appState, insets, route } = this.props;
|
||||||
|
|
||||||
if (route?.params?.jumpToMessageId && route?.params?.jumpToMessageId !== prevProps.route?.params?.jumpToMessageId) {
|
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 it's a livechat room
|
||||||
if (this.t === 'l') {
|
if (this.t === 'l') {
|
||||||
if (
|
if (
|
||||||
!room.lastMessage?.token ||
|
!roomUpdate?.lastMessage?.token ||
|
||||||
!dequal(prevState.roomUpdate.visitor, roomUpdate.visitor) ||
|
!dequal(prevState.roomUpdate.visitor, roomUpdate.visitor) ||
|
||||||
!dequal(prevState.roomUpdate.status, roomUpdate.status) ||
|
!dequal(prevState.roomUpdate.status, roomUpdate.status) ||
|
||||||
prevState.joined !== joined
|
prevState.joined !== joined
|
||||||
|
@ -1277,7 +1278,6 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
|
||||||
dateSeparator = item.ts;
|
dateSeparator = item.ts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log({ item });
|
|
||||||
let content = null;
|
let content = null;
|
||||||
if (item.t && MESSAGE_TYPE_ANY_LOAD.includes(item.t as MessageTypeLoad)) {
|
if (item.t && MESSAGE_TYPE_ANY_LOAD.includes(item.t as MessageTypeLoad)) {
|
||||||
content = (
|
content = (
|
||||||
|
|
Loading…
Reference in New Issue