mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 08:58:38 +01:00
Adjust some types
This commit is contained in:
+9
-12
@@ -168,13 +168,10 @@ export type AttachmentDraftType =
|
||||
size: number;
|
||||
};
|
||||
|
||||
export type ThumbnailType = {
|
||||
height?: number;
|
||||
width?: number;
|
||||
url?: string;
|
||||
contentType: MIME.MIMEType;
|
||||
path?: string;
|
||||
data?: Uint8Array;
|
||||
export type ThumbnailType = Pick<
|
||||
AttachmentType,
|
||||
'height' | 'width' | 'url' | 'contentType' | 'path' | 'data'
|
||||
> & {
|
||||
// Only used when quote needed to make an in-memory thumbnail
|
||||
objectUrl?: string;
|
||||
};
|
||||
@@ -236,7 +233,7 @@ export async function migrateDataToFileSystem(
|
||||
// Over time, we can expand this definition to become more narrow, e.g. require certain
|
||||
// fields, etc.
|
||||
export function isValid(
|
||||
rawAttachment?: AttachmentType
|
||||
rawAttachment?: Pick<AttachmentType, 'data' | 'path'>
|
||||
): rawAttachment is AttachmentType {
|
||||
// NOTE: We cannot use `_.isPlainObject` because `rawAttachment` is
|
||||
// deserialized by protobuf:
|
||||
@@ -396,14 +393,14 @@ export function hasData(attachment: AttachmentType): boolean {
|
||||
|
||||
export function loadData(
|
||||
readAttachmentData: (path: string) => Promise<Uint8Array>
|
||||
): (attachment: AttachmentType) => Promise<AttachmentWithHydratedData> {
|
||||
): (
|
||||
attachment: Pick<AttachmentType, 'data' | 'path'>
|
||||
) => Promise<AttachmentWithHydratedData> {
|
||||
if (!is.function_(readAttachmentData)) {
|
||||
throw new TypeError("'readAttachmentData' must be a function");
|
||||
}
|
||||
|
||||
return async (
|
||||
attachment: AttachmentType
|
||||
): Promise<AttachmentWithHydratedData> => {
|
||||
return async attachment => {
|
||||
if (!isValid(attachment)) {
|
||||
throw new TypeError("'attachment' is not valid");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user