Compare commits

...

1 Commits

Author SHA1 Message Date
Reinaldo Neto 51d95e1587 Chore: Migrate Message definition to Typescript 2021-12-21 15:31:27 -03:00
5 changed files with 96 additions and 30 deletions

View File

@ -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({
@ -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;
@ -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}

View File

@ -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'])];
@ -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;

View File

@ -1,4 +1,5 @@
export interface IAttachment {
ts: Date;
title: string;
type: string;
description: string;
@ -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;
}

View File

@ -1,3 +1,71 @@
import Model from '@nozbe/watermelondb/Model';
import { MarkdownAST } from '@rocket.chat/message-parser';
import { IAttachment } from './IAttachment';
import { IReaction } from './IReactions';
import { RoomType } from './IRoom';
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 type TOnLinkPress = (link: string) => void;
export interface ITranslations {
_id: string;
language: string;
value: string;
}
export interface IMessage {
msg: string;
t?: RoomType;
ts: Date;
u: IUserMessage;
subscription: { id: string };
alias: string;
parseUrls: boolean;
groupable: boolean;
avatar: string;
emoji: string;
attachments: IAttachment[];
urls: string[];
_updatedAt: Date;
status: number;
pinned: boolean;
starred: boolean;
editedBy?: { _id: string; username: string };
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;
}
export type TMessageModel = IMessage & Model;

View File

@ -0,0 +1,5 @@
export interface IReaction {
_id: string;
emoji: string;
usernames: string[];
}