Fix quoted media rendering issue.
This commit is contained in:
parent
08f023fb12
commit
b427754a81
2 changed files with 19 additions and 3 deletions
|
@ -125,7 +125,7 @@ public class MediaMmsMessageRecord extends MmsMessageRecord {
|
|||
return partCount;
|
||||
}
|
||||
|
||||
public MediaMmsMessageRecord withAttachments(@NonNull Context context, @NonNull List<DatabaseAttachment> attachments) {
|
||||
public @NonNull MediaMmsMessageRecord withAttachments(@NonNull Context context, @NonNull List<DatabaseAttachment> attachments) {
|
||||
Map<AttachmentId, DatabaseAttachment> attachmentIdMap = new HashMap<>();
|
||||
for (DatabaseAttachment attachment : attachments) {
|
||||
attachmentIdMap.put(attachment.getAttachmentId(), attachment);
|
||||
|
@ -135,13 +135,14 @@ public class MediaMmsMessageRecord extends MmsMessageRecord {
|
|||
Set<Attachment> contactAttachments = contacts.stream().map(Contact::getAvatarAttachment).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
List<LinkPreview> linkPreviews = updateLinkPreviews(getLinkPreviews(), attachmentIdMap);
|
||||
Set<Attachment> linkPreviewAttachments = linkPreviews.stream().map(LinkPreview::getThumbnail).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toSet());
|
||||
Quote quote = updateQuote(context, getQuote(), attachments);
|
||||
|
||||
List<DatabaseAttachment> slideAttachments = attachments.stream().filter(a -> !contactAttachments.contains(a)).filter(a -> !linkPreviewAttachments.contains(a)).collect(Collectors.toList());
|
||||
SlideDeck slideDeck = MmsDatabase.Reader.buildSlideDeck(context, slideAttachments);
|
||||
|
||||
SlideDeck slideDeck = MmsDatabase.Reader.buildSlideDeck(context, slideAttachments);
|
||||
return new MediaMmsMessageRecord(getId(), getRecipient(), getIndividualRecipient(), getRecipientDeviceId(), getDateSent(), getDateReceived(), getServerTimestamp(), getDeliveryReceiptCount(), getThreadId(), getBody(), slideDeck,
|
||||
getPartCount(), getType(), getIdentityKeyMismatches(), getNetworkFailures(), getSubscriptionId(), getExpiresIn(), getExpireStarted(), isViewOnce(),
|
||||
getReadReceiptCount(), getQuote(), contacts, linkPreviews, isUnidentified(), getReactions(), isRemoteDelete(), mentionsSelf,
|
||||
getReadReceiptCount(), quote, contacts, linkPreviews, isUnidentified(), getReactions(), isRemoteDelete(), mentionsSelf,
|
||||
getNotifiedTimestamp(), getViewedReceiptCount());
|
||||
}
|
||||
|
||||
|
@ -178,4 +179,14 @@ public class MediaMmsMessageRecord extends MmsMessageRecord {
|
|||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static @Nullable Quote updateQuote(@NonNull Context context, @Nullable Quote quote, @NonNull List<DatabaseAttachment> attachments) {
|
||||
if (quote == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<DatabaseAttachment> quoteAttachments = attachments.stream().filter(Attachment::isQuote).collect(Collectors.toList());
|
||||
|
||||
return quote.withAttachment(new SlideDeck(context, quoteAttachments));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,11 @@ public class Quote {
|
|||
this.text = spannable;
|
||||
}
|
||||
|
||||
public @NonNull Quote withAttachment(@NonNull SlideDeck updatedAttachment) {
|
||||
return new Quote(id, author, text, missing, updatedAttachment, mentions);
|
||||
}
|
||||
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue