From 5f25abc213d1de3b899e83f2b793268feae253f1 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Thu, 14 Sep 2023 15:12:37 +1000 Subject: [PATCH] add paged database observer for link preview attachment --- .../Conversations/ConversationViewModel.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Session/Conversations/ConversationViewModel.swift b/Session/Conversations/ConversationViewModel.swift index 0bfef4254..7698a6f25 100644 --- a/Session/Conversations/ConversationViewModel.swift +++ b/Session/Conversations/ConversationViewModel.swift @@ -265,6 +265,24 @@ public class ConversationViewModel: OWSAudioPlayerDelegate { .allCases .filter { $0 != .wasRead } ), + PagedData.ObservedChanges( + table: Attachment.self, + columns: [.state], + joinToPagedType: { + let interaction: TypedTableAlias = TypedTableAlias() + let linkPreview: TypedTableAlias = TypedTableAlias() + let linkPreviewAttachment: TypedTableAlias = TypedTableAlias() + + return SQL(""" + LEFT JOIN \(LinkPreview.self) ON ( + \(linkPreview[.url]) = \(interaction[.linkPreviewUrl]) AND + \(Interaction.linkPreviewFilterLiteral()) + ) + LEFT JOIN \(linkPreviewAttachment) ON \(linkPreviewAttachment[.id]) = \(linkPreview[.attachmentId]) + """ + ) + }() + ), PagedData.ObservedChanges( table: Contact.self, columns: [.isTrusted],