diff --git a/app/views/RoomView/index.tsx b/app/views/RoomView/index.tsx index ad5809681..0f3419ac6 100644 --- a/app/views/RoomView/index.tsx +++ b/app/views/RoomView/index.tsx @@ -95,7 +95,9 @@ const stateAttrsUpdate = [ 'readOnly', 'member', 'showingBlockingLoader', - 'omnichannelPermissions' + 'canForwardGuest', + 'canReturnQueue', + 'canViewCannedResponses' ]; const roomAttrsUpdate = [ 'f', @@ -167,7 +169,6 @@ interface IRoomViewState { readOnly: boolean; unreadsCount: number | null; roomUserId?: string | null; - omnichannelPermissions: object; // TODO: Update to proper type } class RoomView extends React.Component { @@ -238,7 +239,9 @@ class RoomView extends React.Component { readOnly: false, unreadsCount: null, roomUserId, - omnichannelPermissions: {} + canViewCannedResponses: false, + canForwardGuest: false, + canReturnQueue: false }; this.setHeader(); @@ -249,10 +252,6 @@ class RoomView extends React.Component { this.findAndObserveRoom(this.rid); } - if (this.t === 'l') { - this.setOmnichannelPermissions(); - } - this.setReadOnly(); this.messagebox = React.createRef(); @@ -372,7 +371,7 @@ class RoomView extends React.Component { roomUpdate.teamId !== prevState.roomUpdate.teamId) && !this.tmid ) { - this.setHeader(); + this.setOmnichannelPermissions(); } if (insets.left !== prevProps.insets.left || insets.right !== prevProps.insets.right) { this.setHeader(); @@ -442,10 +441,8 @@ class RoomView extends React.Component { }; canViewCannedResponse = async () => { - const { room } = this.state; const { viewCannedResponsesPermission } = this.props; - const { rid } = room; - const permissions = await RocketChat.hasPermission([viewCannedResponsesPermission], rid); + const permissions = await RocketChat.hasPermission([viewCannedResponsesPermission], this.rid); return permissions[0]; }; @@ -463,6 +460,7 @@ class RoomView extends React.Component { const canReturnQueue = await this.canReturnQueue(); const canViewCannedResponse = await this.canViewCannedResponse(); this.setState({ canForwardGuest, canReturnQueue, canViewCannedResponse }); + this.setHeader(); }; get isOmnichannel() { @@ -525,7 +523,7 @@ class RoomView extends React.Component { numIconsRight = 3; } const headerTitlePosition = getHeaderTitlePosition({ insets, numIconsRight }); - + const omnichannelPermissions = [canForwardGuest, canReturnQueue]; navigation.setOptions({ headerShown: true, headerTitleAlign: 'left', @@ -573,7 +571,7 @@ class RoomView extends React.Component { teamId={teamId} joined={joined} status={room.status} - omnichannelPermissions={[canForwardGuest, canReturnQueue]} + omnichannelPermissions={omnichannelPermissions} t={this.t || t} encrypted={encrypted} navigation={navigation}