exitRoomAction method

void exitRoomAction()

Implementation

void exitRoomAction() async {
  if (isRoomOwner()) {
    if (RoomStore.to.userInfoList.length > 2) {
      showConferenceBottomSheet(const TransferHostWidget());
    } else if (RoomStore.to.userInfoList.length == 2) {
      var nextOwnerId = RoomStore.to.userInfoList
          .firstWhere((element) =>
              element.userId.value != RoomStore.to.currentUser.userId.value)
          .userId
          .value;
      var result =
          await _engineManager.changeUserRole(nextOwnerId, TUIRole.roomOwner);
      if (result.code == TUIError.success) {
        _exitRoom();
      }
    } else {
      destroyRoomAction();
    }
    return;
  }
  _exitRoom();
}