mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
a6c7e252a7
Removed the logic for 'oversizedText' (not sent by either iOS or Android and not handled at all by desktop) Updated the HomeViewModel (and ConversationCell) to use the same query model as Global Search Added an 'albumIndex' property to the InteractionAttachment so we can enforce a correct order (apparently SQLite doesn't do this by default) Updated the YDB to GRDB migration to avoid creating GroupMembers if the current user isn't a member of a ClosedGroup (be consistent with the running logic) Updated the attachment description logic to be consistent throughout Cleaned up the Interaction preview generation logic
74 lines
2.2 KiB
Swift
74 lines
2.2 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
import GRDB
|
|
|
|
public struct QuotedReplyModel {
|
|
public let threadId: String
|
|
public let authorId: String
|
|
public let timestampMs: Int64
|
|
public let body: String?
|
|
public let attachment: Attachment?
|
|
public let contentType: String?
|
|
public let sourceFileName: String?
|
|
public let thumbnailDownloadFailed: Bool
|
|
|
|
// MARK: - Initialization
|
|
|
|
init(
|
|
threadId: String,
|
|
authorId: String,
|
|
timestampMs: Int64,
|
|
body: String?,
|
|
attachment: Attachment?,
|
|
contentType: String?,
|
|
sourceFileName: String?,
|
|
thumbnailDownloadFailed: Bool
|
|
) {
|
|
self.attachment = attachment
|
|
self.threadId = threadId
|
|
self.authorId = authorId
|
|
self.timestampMs = timestampMs
|
|
self.body = body
|
|
self.contentType = contentType
|
|
self.sourceFileName = sourceFileName
|
|
self.thumbnailDownloadFailed = thumbnailDownloadFailed
|
|
}
|
|
|
|
public static func quotedReplyForSending(
|
|
threadId: String,
|
|
authorId: String,
|
|
variant: Interaction.Variant,
|
|
body: String?,
|
|
timestampMs: Int64,
|
|
attachments: [Attachment]?,
|
|
linkPreview: LinkPreview?
|
|
) -> QuotedReplyModel? {
|
|
guard variant == .standardOutgoing || variant == .standardIncoming else { return nil }
|
|
guard (body != nil && body?.isEmpty == false) || attachments?.isEmpty == false else { return nil }
|
|
|
|
return QuotedReplyModel(
|
|
threadId: threadId,
|
|
authorId: authorId,
|
|
timestampMs: timestampMs,
|
|
body: body,
|
|
attachment: attachments?.first,
|
|
contentType: attachments?.first?.contentType,
|
|
sourceFileName: attachments?.first?.sourceFilename,
|
|
thumbnailDownloadFailed: false
|
|
)
|
|
}
|
|
}
|
|
|
|
// MARK: - Convenience
|
|
|
|
public extension QuotedReplyModel {
|
|
func generateAttachmentThumbnailIfNeeded(_ db: Database) throws -> String? {
|
|
guard let sourceAttachment: Attachment = self.attachment else { return nil }
|
|
|
|
return try sourceAttachment
|
|
.cloneAsThumbnail()?
|
|
.inserted(db)
|
|
.id
|
|
}
|
|
}
|