Skip to content
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ee0eb77
Chore: Migrate Model's folder to Typescript
reinaldonetof Dec 21, 2021
b46f1e8
minor tweak
reinaldonetof Dec 21, 2021
196b2a5
IFrequentlyUsedEmoji
reinaldonetof Dec 21, 2021
6e2f18f
refactor IAttachments
reinaldonetof Dec 21, 2021
23cdabf
IReactions
reinaldonetof Dec 21, 2021
f431163
IMessage created, missing mix with Markdown
reinaldonetof Dec 21, 2021
d613be1
Chore: Migrate CustomEmoji to Typescript
reinaldonetof Dec 21, 2021
80faa18
Chore: Migrate FrequentlyUsedEmoji to Typescript
reinaldonetof Dec 21, 2021
51d95e1
Chore: Migrate Message definition to Typescript
reinaldonetof Dec 21, 2021
3c1d4f7
Chore: Migrate Permission definition to Typescript
reinaldonetof Dec 21, 2021
1068d11
Chore: Migrate Role definition to Typescript
reinaldonetof Dec 21, 2021
9168159
minor tweak
reinaldonetof Dec 21, 2021
027104a
Chore: Migrate Room and Subscription model to Typescript
reinaldonetof Dec 22, 2021
36e2aa7
TRoomModel
reinaldonetof Dec 22, 2021
58ab3b0
refactoring isubscription
reinaldonetof Dec 22, 2021
1ed5644
Merge branch 'chore.ts-definition-frequentlyusedemoji' into chore.ts-…
reinaldonetof Dec 22, 2021
ae8fc39
Merge branch 'chore.ts-definition-customemoji' into chore.ts-modelfolder
reinaldonetof Dec 22, 2021
41062fb
Merge branch 'chore.ts-definition-message' into chore.ts-modelfolder
reinaldonetof Dec 22, 2021
1af8280
Merge branch 'chore.ts-definition-permission' into chore.ts-modelfolder
reinaldonetof Dec 22, 2021
efc306d
Merge branch 'chore.ts-definition-role' into chore.ts-modelfolder
reinaldonetof Dec 22, 2021
107665f
Merge branch 'chore.ts-definition-room' into chore.ts-modelfolder
reinaldonetof Dec 22, 2021
d2a894d
ISubcription almost there, missing the Threads, ThreadsMessages and U…
reinaldonetof Dec 22, 2021
46a18d4
Subscription Model
reinaldonetof Dec 22, 2021
8d7b387
IServerHistory
reinaldonetof Dec 22, 2021
c824825
IServer
reinaldonetof Dec 22, 2021
6e336b4
fix lint serverHistory
reinaldonetof Dec 22, 2021
8352118
LoggedUser
reinaldonetof Dec 22, 2021
29be47b
ISettings
reinaldonetof Dec 22, 2021
5e40d6d
ISlashCommand
reinaldonetof Dec 22, 2021
6783bff
IThread and models
reinaldonetof Dec 22, 2021
cc35a76
IThreadMessage almost there
reinaldonetof Dec 22, 2021
0a918f6
IThreadMessagesModel
reinaldonetof Dec 22, 2021
220e2ba
minor tweak IUrl
reinaldonetof Dec 23, 2021
a23a3e8
IUploads
reinaldonetof Dec 23, 2021
8bf85cb
ISubscription done
reinaldonetof Dec 23, 2021
b5b0a7a
relation to ISubscrition
reinaldonetof Dec 23, 2021
aa16714
optionals to Subscription
reinaldonetof Dec 23, 2021
999d029
IUser done
reinaldonetof Dec 23, 2021
eb217ac
IRoom and IMessage optionals
reinaldonetof Dec 23, 2021
f5ff302
IThread and IThreadMessage optionals
reinaldonetof Dec 23, 2021
14a9921
optionals done
reinaldonetof Dec 23, 2021
7c8c48d
Merge branch 'develop' into chore.ts-modelfolder
diegolmello Jan 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 6 additions & 22 deletions app/containers/message/Reply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { themes } from '../../constants/colors';
import MessageContext from './Context';
import { fileDownloadAndPreview } from '../../utils/fileDownload';
import { formatAttachmentUrl } from '../../lib/utils';
import { IAttachment } from '../../definitions/IAttachment';
import RCActivityIndicator from '../ActivityIndicator';

const styles = StyleSheet.create({
Expand Down Expand Up @@ -90,43 +91,26 @@ const styles = StyleSheet.create({
}
});

interface IMessageReplyAttachment {
author_name: string;
message_link: string;
ts: string;
text: string;
title: string;
short: boolean;
value: string;
title_link: string;
author_link: string;
type: string;
color: string;
description: string;
fields: IMessageReplyAttachment[];
thumb_url: string;
}

interface IMessageTitle {
attachment: Partial<IMessageReplyAttachment>;
attachment: IAttachment;
timeFormat: string;
theme: string;
}

interface IMessageDescription {
attachment: Partial<IMessageReplyAttachment>;
attachment: IAttachment;
getCustomEmoji: Function;
theme: string;
}

interface IMessageFields {
attachment: Partial<IMessageReplyAttachment>;
attachment: IAttachment;
theme: string;
getCustomEmoji: Function;
}

interface IMessageReply {
attachment: IMessageReplyAttachment;
attachment: IAttachment;
timeFormat: string;
index: number;
theme: string;
Expand Down Expand Up @@ -198,7 +182,7 @@ const Fields = React.memo(
<Text style={[styles.fieldTitle, { color: themes[theme].bodyText }]}>{field.title}</Text>
{/* @ts-ignore*/}
<Markdown
msg={field.value}
msg={field.value!}
baseUrl={baseUrl}
username={user.username}
getCustomEmoji={getCustomEmoji}
Expand Down
10 changes: 2 additions & 8 deletions app/containers/message/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { fileDownload } from '../../utils/fileDownload';
import EventEmitter from '../../utils/events';
import { LISTENER } from '../Toast';
import I18n from '../../i18n';
import { IAttachment } from '../../definitions/IAttachment';
import RCActivityIndicator from '../ActivityIndicator';

const SUPPORTED_TYPES = ['video/quicktime', 'video/mp4', ...(isIOS ? [] : ['video/3gp', 'video/mkv'])];
Expand All @@ -30,14 +31,7 @@ const styles = StyleSheet.create({
});

interface IMessageVideo {
file: {
title: string;
title_link: string;
type: string;
video_type: string;
video_url: string;
description: string;
};
file: IAttachment;
showAttachment: Function;
getCustomEmoji: Function;
theme: string;
Expand Down
15 changes: 15 additions & 0 deletions app/definitions/IAttachment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface IAttachment {
ts: Date;
title: string;
type: string;
description: string;
Expand All @@ -7,4 +8,18 @@ export interface IAttachment {
image_type?: string;
video_url?: string;
video_type?: string;
title_link_download?: boolean;
fields?: IAttachment[];
image_dimensions?: { width?: number; height?: number };
image_preview?: string;
image_size?: number;
author_name?: string;
author_icon?: string;
message_link?: string;
text?: string;
short?: boolean;
value?: string;
author_link?: string;
color?: string;
thumb_url?: string;
}
10 changes: 10 additions & 0 deletions app/definitions/ICustomEmoji.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Model from '@nozbe/watermelondb/Model';

export interface ICustomEmoji {
name?: string;
aliases?: string;
extension: string;
_updatedAt: Date;
}

export type TCustomEmojiModel = ICustomEmoji & Model;
10 changes: 10 additions & 0 deletions app/definitions/IFrequentlyUsedEmoji.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Model from '@nozbe/watermelondb/Model';

export interface IFrequentlyUsedEmoji {
content?: string;
extension?: string;
isCustom: boolean;
count: number;
}

export type TFrequentlyUsedEmoji = IFrequentlyUsedEmoji & Model;
18 changes: 18 additions & 0 deletions app/definitions/ILoggedUser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Model from '@nozbe/watermelondb/Model';

export interface ILoggedUser {
id: string;
token: string;
username: string;
name: string;
language?: string;
status: string;
statusText?: string;
roles: string[];
avatarETag?: string;
showMessageInMainThread: boolean;
isFromWebView: boolean;
enableMessageParserEarlyAdoption?: boolean;
}

export type TLoggedUser = ILoggedUser & Model;
94 changes: 93 additions & 1 deletion app/definitions/IMessage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,95 @@
export interface IMessage {
import Model from '@nozbe/watermelondb/Model';
import { MarkdownAST } from '@rocket.chat/message-parser';

import { IAttachment } from './IAttachment';
import { IReaction } from './IReaction';
import { SubscriptionType } from './ISubscription';

export interface IUserMessage {
_id: string;
username?: string;
name?: string;
}

export interface IUserMention extends IUserMessage {
type: string;
}

export interface IUserChannel {
[index: number]: string | number;
name: string;
_id: string;
}

export interface IEditedBy {
_id: string;
username: string;
}

export type TOnLinkPress = (link: string) => void;

export interface ITranslations {
_id: string;
language: string;
value: string;
}

export interface ILastMessage {
_id: string;
rid: string;
tshow: boolean;
tmid: string;
msg: string;
ts: Date;
u: IUserMessage;
_updatedAt: Date;
urls: string[];
mentions: IUserMention[];
channels: IUserChannel[];
md: MarkdownAST;
attachments: IAttachment[];
reactions: IReaction[];
unread: boolean;
status: boolean;
}

export interface IMessage {
msg?: string;
t?: SubscriptionType;
ts: Date;
u: IUserMessage;
alias: string;
parseUrls: boolean;
groupable?: boolean;
avatar?: string;
emoji?: string;
attachments?: IAttachment[];
urls?: string[];
_updatedAt: Date;
status?: number;
pinned?: boolean;
starred?: boolean;
editedBy?: IEditedBy;
reactions?: IReaction[];
role?: string;
drid?: string;
dcount?: number;
dlm?: Date;
tmid?: string;
tcount?: number;
tlm?: Date;
replies?: string[];
mentions?: IUserMention[];
channels?: IUserChannel[];
unread?: boolean;
autoTranslate?: boolean;
translations?: ITranslations[];
tmsg?: string;
blocks?: any;
e2e?: string;
tshow?: boolean;
md?: MarkdownAST;
subscription: { id: string };
}

export type TMessageModel = IMessage & Model;
9 changes: 9 additions & 0 deletions app/definitions/IPermission.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Model from '@nozbe/watermelondb/Model';

export interface IPermission {
id: string;
roles: string[];
_updatedAt: Date;
}

export type TPermissionModel = IPermission & Model;
5 changes: 5 additions & 0 deletions app/definitions/IReaction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface IReaction {
_id: string;
emoji: string;
usernames: string[];
}
4 changes: 0 additions & 4 deletions app/definitions/IRocketChatRecord.ts

This file was deleted.

8 changes: 8 additions & 0 deletions app/definitions/IRole.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Model from '@nozbe/watermelondb/Model';

export interface IRole {
id: string;
description?: string;
}

export type TRoleModel = IRole & Model;
41 changes: 17 additions & 24 deletions app/definitions/IRoom.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
import { IRocketChatRecord } from './IRocketChatRecord';
import Model from '@nozbe/watermelondb/Model';

export enum RoomType {
GROUP = 'p',
DIRECT = 'd',
CHANNEL = 'c',
OMNICHANNEL = 'l',
THREAD = 'thread'
}
import { IServedBy } from './IServedBy';

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;
ro: boolean;
v?: string[];
servedBy?: IServedBy;
departmentId?: string;
livechatData?: any;
tags?: string[];
e2eKeyId?: string;
avatarETag?: string;
}

export type TRoomModel = IRoom & Model;
5 changes: 5 additions & 0 deletions app/definitions/IServedBy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface IServedBy {
_id: string;
username: string;
ts: Date;
}
4 changes: 4 additions & 0 deletions app/definitions/IServer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Model from '@nozbe/watermelondb/Model';

export interface IServer {
name: string;
iconURL: string;
Expand All @@ -14,3 +16,5 @@ export interface IServer {
enterpriseModules: string;
E2E_Enable: boolean;
}

export type TServerModel = IServer & Model;
10 changes: 10 additions & 0 deletions app/definitions/IServerHistory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Model from '@nozbe/watermelondb/Model';

export interface IServerHistory {
id: string;
url: string;
username: string;
updatedAt: Date;
}

export type TServerHistory = IServerHistory & Model;
12 changes: 12 additions & 0 deletions app/definitions/ISettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Model from '@nozbe/watermelondb/Model';

export interface ISettings {
id: string;
valueAsString?: string;
valueAsBoolean?: boolean;
valueAsNumber?: number;
valueAsArray?: string[];
_updatedAt?: Date;
}

export type TSettingsModel = ISettings & Model;
12 changes: 12 additions & 0 deletions app/definitions/ISlashCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Model from '@nozbe/watermelondb/Model';

export interface ISlashCommand {
id: string;
params?: string;
description?: string;
clientOnly?: boolean;
providesPreview?: boolean;
appId?: string;
}

export type TSlashCommandModel = ISlashCommand & Model;
Loading