From 82ceb044e3ab722435d86a6e32fdf14076276ef0 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 23 Jan 2019 11:54:31 -0500 Subject: [PATCH] Use link preview image when quote replying. --- SignalMessaging/ViewModels/OWSQuotedReplyModel.m | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/SignalMessaging/ViewModels/OWSQuotedReplyModel.m b/SignalMessaging/ViewModels/OWSQuotedReplyModel.m index b2436a2f2..a8f6eaa66 100644 --- a/SignalMessaging/ViewModels/OWSQuotedReplyModel.m +++ b/SignalMessaging/ViewModels/OWSQuotedReplyModel.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "OWSQuotedReplyModel.h" @@ -165,7 +165,6 @@ NS_ASSUME_NONNULL_BEGIN NSString *_Nullable quotedText = message.body; BOOL hasText = quotedText.length > 0; - BOOL hasAttachment = NO; TSAttachment *_Nullable attachment = [message attachmentsWithTransaction:transaction].firstObject; TSAttachmentStream *quotedAttachment; @@ -213,10 +212,16 @@ NS_ASSUME_NONNULL_BEGIN } } else { quotedAttachment = attachmentStream; - hasAttachment = YES; } } + if (!quotedAttachment && conversationItem.linkPreview && conversationItem.linkPreviewAttachment && + [conversationItem.linkPreviewAttachment isKindOfClass:[TSAttachmentStream class]]) { + + quotedAttachment = (TSAttachmentStream *)conversationItem.linkPreviewAttachment; + } + + BOOL hasAttachment = quotedAttachment != nil; if (!hasText && !hasAttachment) { OWSFailDebug(@"quoted message has neither text nor attachment"); quotedText = @"";