diff --git a/app/definitions/IRocketChatRecord.ts b/app/definitions/IRocketChatRecord.ts deleted file mode 100644 index 48d91fa84..000000000 --- a/app/definitions/IRocketChatRecord.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface IRocketChatRecord { - id: string; - updatedAt: Date; -} diff --git a/app/definitions/IRoom.ts b/app/definitions/IRoom.ts index 786c1d7c8..e83416612 100644 --- a/app/definitions/IRoom.ts +++ b/app/definitions/IRoom.ts @@ -1,27 +1,16 @@ -import { IRocketChatRecord } from './IRocketChatRecord'; +import { IServedBy } from './IServedBy'; -export enum RoomType { - GROUP = 'p', - DIRECT = 'd', - CHANNEL = 'c', - OMNICHANNEL = 'l', - THREAD = 'thread' -} - -export interface IRoom extends IRocketChatRecord { - rid: string; - t: RoomType; - name: string; - fname: string; - prid?: string; - tmid?: string; - topic?: string; - teamMain?: boolean; - teamId?: string; - encrypted?: boolean; - visitor?: boolean; - autoTranslateLanguage?: boolean; - autoTranslate?: boolean; - observe?: Function; - usedCannedResponse: string; +export interface IRoom { + id: string; + customFields: string[]; + broadcast: boolean; + encrypted: boolean; + e2eKeyId?: string; + ro: boolean; + v: string[]; + servedBy: IServedBy; + departmentId: string; + livechatData?: any; + tags?: string[]; + avatarETag?: string; } diff --git a/app/definitions/IServedBy.ts b/app/definitions/IServedBy.ts new file mode 100644 index 000000000..4bf31aad2 --- /dev/null +++ b/app/definitions/IServedBy.ts @@ -0,0 +1,5 @@ +export interface IServedBy { + _id: string; + username: string; + ts: Date; +} diff --git a/app/definitions/ISubscription.ts b/app/definitions/ISubscription.ts new file mode 100644 index 000000000..ec5cd9ade --- /dev/null +++ b/app/definitions/ISubscription.ts @@ -0,0 +1,27 @@ +export enum SubscriptionType { + GROUP = 'p', + DIRECT = 'd', + CHANNEL = 'c', + OMNICHANNEL = 'l', + THREAD = 'thread' +} + +export interface ISubscription { + id: string; + updatedAt: Date; + rid: string; + t: SubscriptionType; + name: string; + fname: string; + prid?: string; + tmid?: string; + topic?: string; + teamMain?: boolean; + teamId?: string; + encrypted?: boolean; + visitor?: boolean; + autoTranslateLanguage?: boolean; + autoTranslate?: boolean; + observe?: Function; + usedCannedResponse: string; +} diff --git a/app/navigationTypes.ts b/app/navigationTypes.ts index 568b75d0f..cbf17f42e 100644 --- a/app/navigationTypes.ts +++ b/app/navigationTypes.ts @@ -1,6 +1,6 @@ import { NavigatorScreenParams } from '@react-navigation/core'; -import { IRoom } from './definitions/IRoom'; +import { ISubscription } from './definitions/ISubscription'; import { IServer } from './definitions/IServer'; import { IAttachment } from './definitions/IAttachment'; import { MasterDetailInsideStackParamList } from './stacks/MasterDetailStack/types'; @@ -28,7 +28,7 @@ export type ShareInsideStackParamList = { isShareExtension: boolean; serverInfo: IServer; text: string; - room: IRoom; + room: ISubscription; thread: any; // TODO: Change }; SelectServerView: undefined; diff --git a/app/stacks/MasterDetailStack/types.ts b/app/stacks/MasterDetailStack/types.ts index 202ad6014..242c13bab 100644 --- a/app/stacks/MasterDetailStack/types.ts +++ b/app/stacks/MasterDetailStack/types.ts @@ -3,18 +3,18 @@ import { NavigatorScreenParams } from '@react-navigation/core'; import { IAttachment } from '../../definitions/IAttachment'; import { IMessage } from '../../definitions/IMessage'; -import { IRoom, RoomType } from '../../definitions/IRoom'; +import { ISubscription, SubscriptionType } from '../../definitions/ISubscription'; export type MasterDetailChatsStackParamList = { RoomView: { rid: string; - t: RoomType; + t: SubscriptionType; tmid?: string; message?: string; name?: string; fname?: string; prid?: string; - room: IRoom; + room: ISubscription; jumpToMessageId?: string; jumpToThreadId?: string; roomUserId?: string; @@ -27,17 +27,17 @@ export type MasterDetailDrawerParamList = { export type ModalStackParamList = { RoomActionsView: { - room: IRoom; + room: ISubscription; member: any; rid: string; - t: RoomType; + t: SubscriptionType; joined: boolean; }; RoomInfoView: { - room: IRoom; + room: ISubscription; member: any; rid: string; - t: RoomType; + t: SubscriptionType; }; SelectListView: { data: any; @@ -54,11 +54,11 @@ export type ModalStackParamList = { }; RoomMembersView: { rid: string; - room: IRoom; + room: ISubscription; }; SearchMessagesView: { rid: string; - t: RoomType; + t: SubscriptionType; encrypted?: boolean; showCloseModal?: boolean; }; @@ -84,18 +84,18 @@ export type ModalStackParamList = { }; MessagesView: { rid: string; - t: RoomType; + t: SubscriptionType; name: string; }; AutoTranslateView: { rid: string; - room: IRoom; + room: ISubscription; }; DirectoryView: undefined; QueueListView: undefined; NotificationPrefView: { rid: string; - room: IRoom; + room: ISubscription; }; ForwardLivechatView: { rid: string; @@ -110,10 +110,10 @@ export type ModalStackParamList = { scopeName: string; tags: string[]; }; - room: IRoom; + room: ISubscription; }; LivechatEditView: { - room: IRoom; + room: ISubscription; roomUser: any; // TODO: Change }; PickerView: { @@ -126,7 +126,7 @@ export type ModalStackParamList = { }; ThreadMessagesView: { rid: string; - t: RoomType; + t: SubscriptionType; }; TeamChannelsView: { teamId: string; @@ -160,7 +160,7 @@ export type ModalStackParamList = { teamId?: string; }; CreateDiscussionView: { - channel: IRoom; + channel: ISubscription; message: IMessage; showCloseModal: boolean; }; @@ -194,7 +194,7 @@ export type MasterDetailInsideStackParamList = { isShareView?: boolean; serverInfo: {}; text: string; - room: IRoom; + room: ISubscription; thread: any; // TODO: Change }; }; diff --git a/app/stacks/types.ts b/app/stacks/types.ts index 3107c69ce..5a26caabf 100644 --- a/app/stacks/types.ts +++ b/app/stacks/types.ts @@ -6,28 +6,28 @@ import { IOptionsField } from '../views/NotificationPreferencesView/options'; import { IServer } from '../definitions/IServer'; import { IAttachment } from '../definitions/IAttachment'; import { IMessage } from '../definitions/IMessage'; -import { IRoom, RoomType } from '../definitions/IRoom'; +import { ISubscription, SubscriptionType } from '../definitions/ISubscription'; export type ChatsStackParamList = { RoomsListView: undefined; RoomView: { rid: string; - t: RoomType; + t: SubscriptionType; tmid?: string; message?: string; name?: string; fname?: string; prid?: string; - room: IRoom; + room: ISubscription; jumpToMessageId?: string; jumpToThreadId?: string; roomUserId?: string; }; RoomActionsView: { - room: IRoom; + room: ISubscription; member: any; rid: string; - t: RoomType; + t: SubscriptionType; joined: boolean; }; SelectListView: { @@ -41,21 +41,21 @@ export type ChatsStackParamList = { isRadio?: boolean; }; RoomInfoView: { - room: IRoom; + room: ISubscription; member: any; rid: string; - t: RoomType; + t: SubscriptionType; }; RoomInfoEditView: { rid: string; }; RoomMembersView: { rid: string; - room: IRoom; + room: ISubscription; }; SearchMessagesView: { rid: string; - t: RoomType; + t: SubscriptionType; encrypted?: boolean; showCloseModal?: boolean; }; @@ -74,12 +74,12 @@ export type ChatsStackParamList = { }; MessagesView: { rid: string; - t: RoomType; + t: SubscriptionType; name: string; }; AutoTranslateView: { rid: string; - room: IRoom; + room: ISubscription; }; DirectoryView: undefined; NotificationPrefView: { @@ -90,7 +90,7 @@ export type ChatsStackParamList = { rid: string; }; LivechatEditView: { - room: IRoom; + room: ISubscription; roomUser: any; // TODO: Change }; PickerView: { @@ -103,7 +103,7 @@ export type ChatsStackParamList = { }; ThreadMessagesView: { rid: string; - t: RoomType; + t: SubscriptionType; }; TeamChannelsView: { teamId: string; @@ -138,7 +138,7 @@ export type ChatsStackParamList = { scopeName: string; tags: string[]; }; - room: IRoom; + room: ISubscription; }; }; @@ -198,7 +198,7 @@ export type NewMessageStackParamList = { teamId?: string; }; CreateDiscussionView: { - channel: IRoom; + channel: ISubscription; message: IMessage; showCloseModal: boolean; }; @@ -230,7 +230,7 @@ export type InsideStackParamList = { isShareExtension: boolean; serverInfo: IServer; text: string; - room: IRoom; + room: ISubscription; thread: any; // TODO: Change }; ModalBlockView: { diff --git a/app/views/AutoTranslateView/index.tsx b/app/views/AutoTranslateView/index.tsx index f840ca12a..954426891 100644 --- a/app/views/AutoTranslateView/index.tsx +++ b/app/views/AutoTranslateView/index.tsx @@ -11,7 +11,7 @@ import { SWITCH_TRACK_COLOR, themes } from '../../constants/colors'; import { withTheme } from '../../theme'; import SafeAreaView from '../../containers/SafeAreaView'; import { events, logEvent } from '../../utils/log'; -import { IRoom } from '../../definitions/IRoom'; +import { ISubscription } from '../../definitions/ISubscription'; const styles = StyleSheet.create({ list: { @@ -42,7 +42,7 @@ class AutoTranslateView extends React.Component { if (room && room.observe) { this.roomObservable = room.observe(); - this.subscription = this.roomObservable.subscribe((changes: IRoom) => { + this.subscription = this.roomObservable.subscribe((changes: ISubscription) => { if (this.mounted) { const { selectedLanguage, enableAutoTranslate } = this.state; if (selectedLanguage !== changes.autoTranslateLanguage) { diff --git a/app/views/MessagesView/index.tsx b/app/views/MessagesView/index.tsx index 14532051b..c9e3d601d 100644 --- a/app/views/MessagesView/index.tsx +++ b/app/views/MessagesView/index.tsx @@ -20,7 +20,7 @@ import SafeAreaView from '../../containers/SafeAreaView'; import getThreadName from '../../lib/methods/getThreadName'; import styles from './styles'; import { ChatsStackParamList } from '../../stacks/types'; -import { IRoom, RoomType } from '../../definitions/IRoom'; +import { ISubscription, SubscriptionType } from '../../definitions/ISubscription'; interface IMessagesViewProps { user: { @@ -40,10 +40,10 @@ interface IMessagesViewProps { } interface IRoomInfoParam { - room: IRoom; + room: ISubscription; member: any; rid: string; - t: RoomType; + t: SubscriptionType; joined: boolean; } @@ -72,13 +72,13 @@ interface IMessageItem { interface IParams { rid: string; - t: RoomType; + t: SubscriptionType; tmid?: string; message?: string; name?: string; fname?: string; prid?: string; - room: IRoom; + room: ISubscription; jumpToMessageId?: string; jumpToThreadId?: string; roomUserId?: string; @@ -86,7 +86,7 @@ interface IParams { class MessagesView extends React.Component { private rid: string; - private t: RoomType; + private t: SubscriptionType; private content: any; private room: any; @@ -158,7 +158,7 @@ class MessagesView extends React.Component { ...params, tmid: item.tmid, name: await getThreadName(this.rid, item.tmid, item._id), - t: RoomType.THREAD + t: SubscriptionType.THREAD }; navigation.push('RoomView', params); } else { diff --git a/app/views/SearchMessagesView/index.tsx b/app/views/SearchMessagesView/index.tsx index a85df6745..7bc3c1738 100644 --- a/app/views/SearchMessagesView/index.tsx +++ b/app/views/SearchMessagesView/index.tsx @@ -6,7 +6,7 @@ import { Q } from '@nozbe/watermelondb'; import { connect } from 'react-redux'; import { dequal } from 'dequal'; -import { IRoom, RoomType } from '../../definitions/IRoom'; +import { ISubscription, SubscriptionType } from '../../definitions/ISubscription'; import { IAttachment } from '../../definitions/IAttachment'; import RCTextInput from '../../containers/TextInput'; import ActivityIndicator from '../../containers/ActivityIndicator'; @@ -42,10 +42,10 @@ interface ISearchMessagesViewState { } interface IRoomInfoParam { - room: IRoom; + room: ISubscription; member: any; rid: string; - t: RoomType; + t: SubscriptionType; joined: boolean; } diff --git a/app/views/ShareView/index.tsx b/app/views/ShareView/index.tsx index a3ad287aa..d77ba022b 100644 --- a/app/views/ShareView/index.tsx +++ b/app/views/ShareView/index.tsx @@ -28,7 +28,7 @@ import Preview from './Preview'; import Header from './Header'; import styles from './styles'; import { IAttachment } from './interfaces'; -import { IRoom } from '../../definitions/IRoom'; +import { ISubscription } from '../../definitions/ISubscription'; interface IShareViewState { selected: IAttachment; @@ -36,7 +36,7 @@ interface IShareViewState { readOnly: boolean; attachments: IAttachment[]; text: string; - room: IRoom; + room: ISubscription; thread: any; // change maxFileSize: number; mediaAllowList: number;