feat: consolidated attachment types

pull/3170/head
yougotwill 1 year ago
parent 24b3feb39e
commit bdbc48590e

@ -25,6 +25,7 @@ import {
PropsForCallNotification,
PropsForInteractionNotification,
} from './types';
import { AttachmentType } from '../../types/Attachment';
export type MessageModelPropsWithoutConvoProps = {
propsForMessage: PropsForMessageWithoutConvoProps;
@ -128,35 +129,13 @@ export type PropsForGroupInvitation = {
messageId: string;
};
export type PropsForAttachment = {
export type PropsForAttachment = AttachmentType & {
id: number;
contentType: string;
caption?: string;
isVoiceMessage: boolean;
size: number;
width?: number;
height?: number;
duration?: string;
url: string;
path: string;
fileSize: string | null;
isVoiceMessage: boolean;
pending: boolean;
fileName: string;
error?: number; // if the download somhehow failed, this will be set to true and be 0-1 once saved in the db
screenshot: {
contentType: string;
width: number;
height: number;
url?: string;
path?: string;
} | null;
thumbnail: {
contentType: string;
width: number;
height: number;
url?: string;
path?: string;
} | null;
error?: number; // if the download somehow failed, this will be set to true and be 0 or 1 in the db
};
export type PropsForQuote = {

@ -13,35 +13,40 @@ const MAX_HEIGHT = THUMBNAIL_SIDE;
const MIN_WIDTH = THUMBNAIL_SIDE;
const MIN_HEIGHT = THUMBNAIL_SIDE;
// Used for display
// Used for displaying attachments in the UI
export type AttachmentScreenshot = {
contentType: MIME.MIMEType;
height: number;
width: number;
url?: string;
path?: string;
};
export type AttachmentThumbnail = {
contentType: MIME.MIMEType;
height: number;
width: number;
url?: string;
path?: string;
};
export interface AttachmentType {
caption?: string;
contentType: MIME.MIMEType;
fileName: string;
/** Not included in protobuf, needs to be pulled from flags */
isVoiceMessage?: boolean;
/** For messages not already on disk, this will be a data url */
url: string;
videoUrl?: string;
size?: number;
fileSize: string | null;
pending?: boolean;
screenshot: AttachmentScreenshot | null;
thumbnail: AttachmentThumbnail | null;
caption?: string;
size?: number;
width?: number;
height?: number;
duration?: string;
screenshot: {
height: number;
width: number;
url?: string;
contentType: MIME.MIMEType;
} | null;
thumbnail: {
height: number;
width: number;
url?: string;
contentType: MIME.MIMEType;
} | null;
videoUrl?: string;
/** Not included in protobuf, needs to be pulled from flags */
isVoiceMessage?: boolean;
}
export interface AttachmentTypeWithPath extends AttachmentType {
@ -49,21 +54,6 @@ export interface AttachmentTypeWithPath extends AttachmentType {
id: number;
flags?: number;
error?: any;
screenshot: {
height: number;
width: number;
url?: string;
contentType: MIME.MIMEType;
path?: string;
} | null;
thumbnail: {
height: number;
width: number;
url?: string;
contentType: MIME.MIMEType;
path?: string;
} | null;
}
// UI-focused functions

Loading…
Cancel
Save