message: [CHORE] Refactor RoomActionsView permissions
diff: @@ -125,18 +125,22 @@ class RoomActionsView extends React.Component {
  this.updateRoomMember();
  }
  - const canAutoTranslate = RocketChat.canAutoTranslate();
  - this.setState({ canAutoTranslate });
  -
  - this.canAddUser();
  - this.canInviteUser();
  - this.canEdit();
  - this.canToggleEncryption();
  + const canAutoTranslate = await RocketChat.canAutoTranslate();
  + const canAddUser = await this.canAddUser();
  + const canInviteUser = await this.canInviteUser();
  + const canEdit = await this.canEdit();
  + const canToggleEncryption = await this.canToggleEncryption();
  + const canViewMembers = await this.canViewMembers();
  +
  + this.setState({
  + canAutoTranslate, canAddUser, canInviteUser, canEdit, canToggleEncryption, canViewMembers
  + });
  // livechat permissions
  if (room.t === 'l') {
  - this.canForwardGuest();
  - this.canReturnQueue();
  + const canForwardGuest = await this.canForwardGuest();
  + const canReturnQueue = await this.canReturnQueue();
  + this.setState({ canForwardGuest, canReturnQueue });
  }
  }
  }
  @@ -182,7 +186,7 @@ class RoomActionsView extends React.Component {
  if (t === 'p' && permissions[2]) {
  canAddUser = true;
  }
  - this.setState({ canAddUser });
  + return canAddUser;
  }
  canInviteUser = async() => {
  @@ -192,7 +196,7 @@ class RoomActionsView extends React.Component {
  const permissions = await RocketChat.hasPermission([createInviteLinksPermission], rid);
  const canInviteUser = permissions[0];
  - this.setState({ canInviteUser });
  + return canInviteUser;
  }
  canEdit = async() => {
  @@ -202,7 +206,7 @@ class RoomActionsView extends React.Component {
  const permissions = await RocketChat.hasPermission([editRoomPermission], rid);
  const canEdit = permissions[0];
  - this.setState({ canEdit });
  + return canEdit;
  }
  canToggleEncryption = async() => {
  @@ -212,7 +216,7 @@ class RoomActionsView extends React.Component {
  const permissions = await RocketChat.hasPermission([toggleRoomE2EEncryptionPermission], rid);
  const canToggleEncryption = permissions[0];
  - this.setState({ canToggleEncryption });
  + return canToggleEncryption;
  }
  canViewMembers = async() => {
  @@ -229,7 +233,6 @@ class RoomActionsView extends React.Component {
  // This method is executed only in componentDidMount and returns a value
  // We save the state to read in render
  const result = (t === 'c' || t === 'p');
  - this.setState({ canViewMembers: result });
  return result;
  }
  @@ -238,13 +241,13 @@ class RoomActionsView extends React.Component {
  const { transferLivechatGuestPermission } = this.props;
  const { rid } = room;
  const permissions = await RocketChat.hasPermission([transferLivechatGuestPermission], rid);
  - this.setState({ canForwardGuest: permissions[0] });
  + return permissions[0];
  }
  canReturnQueue = async() => {
  try {
  const { returnQueue } = await RocketChat.getRoutingConfig();
  - this.setState({ canReturnQueue: returnQueue });
  + return returnQueue;
  } catch {
  // do nothing
  }
  @@ -582,6 +585,7 @@ class RoomActionsView extends React.Component {
  rid, t, encrypted
  } = room;
  const isGroupChat = RocketChat.isGroupChat(room);
  +
  return (
  <SafeAreaView testID='room-actions-view'>
  <StatusBar />
  