Fixes for media index
This commit is contained in:
parent
e920db2148
commit
156cbca1a3
2 changed files with 14 additions and 7 deletions
|
@ -3401,16 +3401,17 @@ function loadRecentMediaItems(
|
|||
);
|
||||
});
|
||||
|
||||
let index = 0;
|
||||
const recentMediaItems = messages
|
||||
.filter(message => message.attachments !== undefined)
|
||||
.reduce(
|
||||
(acc, message) => [
|
||||
...acc,
|
||||
...(message.attachments || []).map(
|
||||
(attachment: AttachmentType, index: number): MediaItemType => {
|
||||
(attachment: AttachmentType): MediaItemType => {
|
||||
const { thumbnail } = attachment;
|
||||
|
||||
return {
|
||||
const result = {
|
||||
objectURL: getAbsoluteAttachmentPath(attachment.path || ''),
|
||||
thumbnailObjectUrl: thumbnail?.path
|
||||
? getAbsoluteAttachmentPath(thumbnail.path)
|
||||
|
@ -3429,6 +3430,10 @@ function loadRecentMediaItems(
|
|||
sent_at: message.sent_at,
|
||||
},
|
||||
};
|
||||
|
||||
index += 1;
|
||||
|
||||
return result;
|
||||
}
|
||||
),
|
||||
],
|
||||
|
|
|
@ -116,13 +116,11 @@ function loadMediaItems(
|
|||
})
|
||||
);
|
||||
|
||||
let index = 0;
|
||||
const media: Array<MediaType> = rawMedia
|
||||
.flatMap(message => {
|
||||
return (message.attachments || []).map(
|
||||
(
|
||||
attachment: AttachmentType,
|
||||
index: number
|
||||
): MediaType | undefined => {
|
||||
(attachment: AttachmentType): MediaType | undefined => {
|
||||
if (
|
||||
!attachment.path ||
|
||||
!attachment.thumbnail ||
|
||||
|
@ -133,7 +131,7 @@ function loadMediaItems(
|
|||
}
|
||||
|
||||
const { thumbnail } = attachment;
|
||||
return {
|
||||
const result = {
|
||||
path: attachment.path,
|
||||
objectURL: getAbsoluteAttachmentPath(attachment.path),
|
||||
thumbnailObjectUrl: thumbnail?.path
|
||||
|
@ -156,6 +154,10 @@ function loadMediaItems(
|
|||
sent_at: message.sent_at,
|
||||
},
|
||||
};
|
||||
|
||||
index += 1;
|
||||
|
||||
return result;
|
||||
}
|
||||
);
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue