chore: add omnichannel permissions to RightButtons
chore: missing changes to previous commit on RoomView
This commit is contained in:
parent
a2965a3f93
commit
97d4dc9f3b
|
@ -82,16 +82,7 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
|
|||
}
|
||||
}
|
||||
if (t === 'l') {
|
||||
const canReturnQueue = await this.canReturnQueue();
|
||||
const canForwardGuest = await this.canForwardGuest();
|
||||
this.setState({ canReturnQueue, canForwardGuest });
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: IRightButtonsProps) {
|
||||
const { status } = this.props;
|
||||
if (prevProps.status !== status) {
|
||||
return false;
|
||||
this.setOmnichannelPermissions();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,6 +113,14 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
|
|||
return false;
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: IRightButtonsProps) {
|
||||
const { status, joined } = this.props;
|
||||
|
||||
if (prevProps.status !== status || prevProps.joined !== joined) {
|
||||
this.setOmnichannelPermissions();
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this.threadSubscription && this.threadSubscription.unsubscribe) {
|
||||
this.threadSubscription.unsubscribe();
|
||||
|
@ -131,6 +130,12 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
|
|||
}
|
||||
}
|
||||
|
||||
setOmnichannelPermissions = async () => {
|
||||
const canReturnQueue = await this.canReturnQueue();
|
||||
const canForwardGuest = await this.canForwardGuest();
|
||||
this.setState({ canReturnQueue, canForwardGuest });
|
||||
};
|
||||
|
||||
observeThread = (threadRecord: TMessageModel) => {
|
||||
const threadObservable: Observable<TMessageModel> = threadRecord.observe();
|
||||
this.threadSubscription = threadObservable.subscribe(thread => this.updateThread(thread));
|
||||
|
@ -278,13 +283,17 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
|
|||
}
|
||||
};
|
||||
|
||||
isOmnichannelPreview = () => {
|
||||
const { joined, status } = this.props;
|
||||
return joined && status !== 'queued';
|
||||
};
|
||||
|
||||
render() {
|
||||
const { isFollowingThread, tunread, tunreadUser, tunreadGroup } = this.state;
|
||||
const { t, tmid, threadsEnabled, teamId, joined, status } = this.props;
|
||||
const isOmnichannelPreview = joined && status !== 'queued';
|
||||
const { t, tmid, threadsEnabled, teamId, joined } = this.props;
|
||||
|
||||
if (t === 'l') {
|
||||
if (isOmnichannelPreview) {
|
||||
if (this.isOmnichannelPreview()) {
|
||||
return (
|
||||
<HeaderButton.Container>
|
||||
<HeaderButton.Item iconName='kebab' onPress={this.showMoreActions} testID='room-view-header-omnichannel-kebab' />
|
||||
|
|
|
@ -315,7 +315,7 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
|
|||
}
|
||||
|
||||
componentDidUpdate(prevProps: IRoomViewProps, prevState: IRoomViewState) {
|
||||
const { roomUpdate } = this.state;
|
||||
const { roomUpdate, joined } = this.state;
|
||||
const { appState, insets, route } = this.props;
|
||||
|
||||
if (route?.params?.jumpToMessageId && route?.params?.jumpToMessageId !== prevProps.route?.params?.jumpToMessageId) {
|
||||
|
@ -341,7 +341,11 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
|
|||
}
|
||||
// If it's a livechat room
|
||||
if (this.t === 'l') {
|
||||
if (!dequal(prevState.roomUpdate.visitor, roomUpdate.visitor)) {
|
||||
if (
|
||||
!dequal(prevState.roomUpdate.visitor, roomUpdate.visitor) ||
|
||||
!dequal(prevState.roomUpdate.status, roomUpdate.status) ||
|
||||
prevState.joined !== joined
|
||||
) {
|
||||
this.setHeader();
|
||||
}
|
||||
}
|
||||
|
@ -1146,6 +1150,11 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
|
|||
});
|
||||
};
|
||||
|
||||
goToCannedResponses = () => {
|
||||
const { room } = this.state;
|
||||
Navigation.navigate('CannedResponsesListView', { rid: room.rid, room });
|
||||
};
|
||||
|
||||
renderItem = (item: TAnyMessageModel, previousItem: TAnyMessageModel, highlightedMessage?: string) => {
|
||||
const { room, lastOpen, canAutoTranslate } = this.state;
|
||||
const { user, Message_GroupingPeriod, Message_TimeFormat, useRealName, baseUrl, Message_Read_Receipt_Enabled, theme } =
|
||||
|
@ -1279,6 +1288,7 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
|
|||
return (
|
||||
<MessageBox
|
||||
ref={this.messagebox}
|
||||
goToCannedResponses={this.goToCannedResponses}
|
||||
onSubmit={this.sendMessage}
|
||||
rid={this.rid}
|
||||
tmid={this.tmid}
|
||||
|
@ -1338,7 +1348,7 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
|
|||
if ('id' in room) {
|
||||
({ sysMes, bannerClosed, announcement, tunread, ignored } = room);
|
||||
}
|
||||
|
||||
console.log({ room });
|
||||
return (
|
||||
<SafeAreaView style={{ backgroundColor: themes[theme].backgroundColor }} testID='room-view'>
|
||||
<StatusBar />
|
||||
|
|
Loading…
Reference in New Issue