From 93ff94186a81987d207bece951d69c65b8a4783b Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Tue, 11 Apr 2023 11:01:40 +0800 Subject: [PATCH] fix an issue when quoting messages with multiple attachments, the quoted attachment doesn't stay the same. --- SessionMessagingKit/Shared Models/MessageViewModel.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/SessionMessagingKit/Shared Models/MessageViewModel.swift b/SessionMessagingKit/Shared Models/MessageViewModel.swift index 2bc7157fe..e917eab57 100644 --- a/SessionMessagingKit/Shared Models/MessageViewModel.swift +++ b/SessionMessagingKit/Shared Models/MessageViewModel.swift @@ -744,7 +744,12 @@ public extension MessageViewModel { ) AND \(quote[.timestampMs]) = \(interaction[.timestampMs]) ) - LEFT JOIN \(InteractionAttachment.self) ON \(interaction[.id]) = \(interactionAttachment[.interactionId]) + LEFT JOIN \(InteractionAttachment.self) ON \(interactionAttachment[.attachmentId]) = ( + SELECT \(interactionAttachment[.attachmentId]) + FROM \(InteractionAttachment.self) + WHERE \(interaction[.id]) = \(interactionAttachment[.interactionId]) + LIMIT 1 + ) ) AS \(ViewModel.quoteKey) ON \(quote[.interactionId]) = \(interaction[.id]) LEFT JOIN \(Attachment.self) AS \(ViewModel.quoteAttachmentKey) ON \(ViewModel.quoteAttachmentKey).\(attachmentIdColumnLiteral) = \(quote[.attachmentId]) LEFT JOIN \(LinkPreview.self) ON (