add paged database observer for link preview attachment

This commit is contained in:
Ryan Zhao 2023-09-14 15:12:37 +10:00
parent 5088e394f2
commit 5f25abc213
1 changed files with 18 additions and 0 deletions

View File

@ -265,6 +265,24 @@ public class ConversationViewModel: OWSAudioPlayerDelegate {
.allCases
.filter { $0 != .wasRead }
),
PagedData.ObservedChanges(
table: Attachment.self,
columns: [.state],
joinToPagedType: {
let interaction: TypedTableAlias<Interaction> = TypedTableAlias()
let linkPreview: TypedTableAlias<LinkPreview> = TypedTableAlias()
let linkPreviewAttachment: TypedTableAlias<Attachment> = 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],