feat: consolidated attachment types

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

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

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

Loading…
Cancel
Save