From 7deaf92ffb29764835f2fab14f4b798ceee36037 Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Thu, 3 Mar 2022 23:19:50 -0300 Subject: [PATCH 1/2] chore: add rest api return --- app/definitions/IRoom.ts | 1 + app/views/DirectoryView/index.tsx | 36 ++++++++++++++++--------------- app/views/TeamChannelsView.tsx | 21 ++++++++++-------- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/app/definitions/IRoom.ts b/app/definitions/IRoom.ts index f63445a5e01..59067e9b6cb 100644 --- a/app/definitions/IRoom.ts +++ b/app/definitions/IRoom.ts @@ -45,6 +45,7 @@ export interface IRoom { muted?: string[]; teamId?: string; ignored?: string; + joinCodeRequired?: boolean; } export enum OmnichannelSourceType { diff --git a/app/views/DirectoryView/index.tsx b/app/views/DirectoryView/index.tsx index b4b0689bd84..73e6a45c971 100644 --- a/app/views/DirectoryView/index.tsx +++ b/app/views/DirectoryView/index.tsx @@ -157,23 +157,25 @@ class DirectoryView extends React.Component { this.goRoom({ rid: result.room._id, name: item.username, t: 'd' }); } } else if (['p', 'c'].includes(item.t) && !item.teamMain) { - const { room }: any = await RocketChat.getRoomInfo(item._id); - this.goRoom({ - rid: item._id, - name: item.name, - joinCodeRequired: room.joinCodeRequired, - t: item.t, - search: true - }); - } else { - this.goRoom({ - rid: item._id, - name: item.name, - t: item.t, - search: true, - teamMain: item.teamMain, - teamId: item.teamId - }); + const result = await RocketChat.getRoomInfo(item._id); + if (result.success) { + this.goRoom({ + rid: item._id, + name: item.name, + joinCodeRequired: result.room.joinCodeRequired, + t: item.t, + search: true + }); + } else { + this.goRoom({ + rid: item._id, + name: item.name, + t: item.t, + search: true, + teamMain: item.teamMain, + teamId: item.teamId + }); + } } }; diff --git a/app/views/TeamChannelsView.tsx b/app/views/TeamChannelsView.tsx index a76c18ba8b1..38b641acf8b 100644 --- a/app/views/TeamChannelsView.tsx +++ b/app/views/TeamChannelsView.tsx @@ -17,7 +17,7 @@ import RoomHeader from '../containers/RoomHeader'; import SafeAreaView from '../containers/SafeAreaView'; import SearchHeader from '../containers/SearchHeader'; import StatusBar from '../containers/StatusBar'; -import { IApplicationState, IBaseScreen } from '../definitions'; +import { IApplicationState, IBaseScreen, IRoom } from '../definitions'; import { ERoomType } from '../definitions/ERoomType'; import { withDimensions } from '../dimensions'; import I18n from '../i18n'; @@ -348,14 +348,17 @@ class TeamChannelsView extends React.Component; + const result = await RocketChat.getRoomInfo(item._id); + if (result.success) { + params = { + rid: item._id, + name: RocketChat.getRoomTitle(result.room), + joinCodeRequired: result.room.joinCodeRequired, + t: result.room.t, + teamId: result.room.teamId + }; + } if (isMasterDetail) { navigation.pop(); } From 1674a153a7f2f3efb2a1795efaf112b18739cc40 Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Sat, 5 Mar 2022 16:49:41 -0300 Subject: [PATCH 2/2] chore: add rest api return --- app/definitions/IRoom.ts | 2 +- app/definitions/rest/v1/rooms.ts | 4 ++-- app/views/ForwardLivechatView.tsx | 4 ++-- app/views/TeamChannelsView.tsx | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/definitions/IRoom.ts b/app/definitions/IRoom.ts index 59067e9b6cb..8613189a503 100644 --- a/app/definitions/IRoom.ts +++ b/app/definitions/IRoom.ts @@ -45,7 +45,6 @@ export interface IRoom { muted?: string[]; teamId?: string; ignored?: string; - joinCodeRequired?: boolean; } export enum OmnichannelSourceType { @@ -149,6 +148,7 @@ export interface IServerRoomItem { e2eKeyId: string; avatarETag: string; encrypted: boolean; + teamId: string; } export interface IServerRoom { diff --git a/app/definitions/rest/v1/rooms.ts b/app/definitions/rest/v1/rooms.ts index 8306cd68f3c..cb509ee4f41 100644 --- a/app/definitions/rest/v1/rooms.ts +++ b/app/definitions/rest/v1/rooms.ts @@ -1,5 +1,5 @@ import type { IMessage } from '../../IMessage'; -import type { IRoom } from '../../IRoom'; +import type { IRoom, IServerRoomItem } from '../../IRoom'; import type { IUser } from '../../IUser'; export type RoomsEndpoints = { @@ -23,7 +23,7 @@ export type RoomsEndpoints = { }; 'rooms.info': { GET: (params: { roomId: string } | { roomName: string }) => { - room: IRoom; + room: IServerRoomItem; }; }; 'rooms.createDiscussion': { diff --git a/app/views/ForwardLivechatView.tsx b/app/views/ForwardLivechatView.tsx index 21c99a0f690..b1b8f76f5ec 100644 --- a/app/views/ForwardLivechatView.tsx +++ b/app/views/ForwardLivechatView.tsx @@ -7,7 +7,7 @@ import { forwardRoom, ITransferData } from '../actions/room'; import { themes } from '../constants/colors'; import OrSeparator from '../containers/OrSeparator'; import Input from '../containers/UIKit/MultiSelect/Input'; -import { IBaseScreen, IRoom } from '../definitions'; +import { IBaseScreen, IRoom, IServerRoomItem } from '../definitions'; import I18n from '../i18n'; import RocketChat from '../lib/rocketchat'; import { ChatsStackParamList } from '../stacks/types'; @@ -86,7 +86,7 @@ const ForwardLivechatView = ({ navigation, route, theme }: IBaseScreen; + let params = {}; const result = await RocketChat.getRoomInfo(item._id); if (result.success) { params = {