|
|
|
@ -73,6 +73,7 @@ public struct MessageViewModel: FetchableRecordWithRowId, Decodable, Equatable,
|
|
|
|
|
public let id: Int64
|
|
|
|
|
public let variant: Interaction.Variant
|
|
|
|
|
public let timestampMs: Int64
|
|
|
|
|
public let receivedTimestampMs: Int64
|
|
|
|
|
public let authorId: String
|
|
|
|
|
private let authorNameInternal: String?
|
|
|
|
|
public let body: String?
|
|
|
|
@ -122,6 +123,9 @@ public struct MessageViewModel: FetchableRecordWithRowId, Decodable, Equatable,
|
|
|
|
|
/// This value will be used to populate the Context Menu and date header (if present)
|
|
|
|
|
public var dateForUI: Date { Date(timeIntervalSince1970: (TimeInterval(self.timestampMs) / 1000)) }
|
|
|
|
|
|
|
|
|
|
/// This value will be used to populate the Message Info (if present)
|
|
|
|
|
public var receivedDateForUI: Date { Date(timeIntervalSince1970: (TimeInterval(self.receivedTimestampMs) / 1000)) }
|
|
|
|
|
|
|
|
|
|
/// This value specifies whether the body contains only emoji characters
|
|
|
|
|
public let containsOnlyEmoji: Bool?
|
|
|
|
|
|
|
|
|
@ -161,6 +165,7 @@ public struct MessageViewModel: FetchableRecordWithRowId, Decodable, Equatable,
|
|
|
|
|
id: self.id,
|
|
|
|
|
variant: self.variant,
|
|
|
|
|
timestampMs: self.timestampMs,
|
|
|
|
|
receivedTimestampMs: self.receivedTimestampMs,
|
|
|
|
|
authorId: self.authorId,
|
|
|
|
|
authorNameInternal: self.authorNameInternal,
|
|
|
|
|
body: self.body,
|
|
|
|
@ -316,6 +321,7 @@ public struct MessageViewModel: FetchableRecordWithRowId, Decodable, Equatable,
|
|
|
|
|
id: self.id,
|
|
|
|
|
variant: self.variant,
|
|
|
|
|
timestampMs: self.timestampMs,
|
|
|
|
|
receivedTimestampMs: self.receivedTimestampMs,
|
|
|
|
|
authorId: self.authorId,
|
|
|
|
|
authorNameInternal: self.authorNameInternal,
|
|
|
|
|
body: (!self.variant.isInfoMessage ?
|
|
|
|
@ -494,6 +500,7 @@ public extension MessageViewModel {
|
|
|
|
|
init(
|
|
|
|
|
variant: Interaction.Variant = .standardOutgoing,
|
|
|
|
|
timestampMs: Int64 = Int64.max,
|
|
|
|
|
receivedTimestampMs: Int64 = Int64.max,
|
|
|
|
|
body: String? = nil,
|
|
|
|
|
quote: Quote? = nil,
|
|
|
|
|
cellType: CellType = .typingIndicator,
|
|
|
|
@ -520,6 +527,7 @@ public extension MessageViewModel {
|
|
|
|
|
self.id = targetId
|
|
|
|
|
self.variant = variant
|
|
|
|
|
self.timestampMs = timestampMs
|
|
|
|
|
self.receivedTimestampMs = receivedTimestampMs
|
|
|
|
|
self.authorId = ""
|
|
|
|
|
self.authorNameInternal = nil
|
|
|
|
|
self.body = body
|
|
|
|
@ -650,7 +658,7 @@ public extension MessageViewModel {
|
|
|
|
|
let groupMemberProfileIdColumnLiteral: SQL = SQL(stringLiteral: GroupMember.Columns.profileId.name)
|
|
|
|
|
let groupMemberRoleColumnLiteral: SQL = SQL(stringLiteral: GroupMember.Columns.role.name)
|
|
|
|
|
|
|
|
|
|
let numColumnsBeforeLinkedRecords: Int = 20
|
|
|
|
|
let numColumnsBeforeLinkedRecords: Int = 21
|
|
|
|
|
let finalGroupSQL: SQL = (groupSQL ?? "")
|
|
|
|
|
let request: SQLRequest<ViewModel> = """
|
|
|
|
|
SELECT
|
|
|
|
@ -668,6 +676,7 @@ public extension MessageViewModel {
|
|
|
|
|
\(interaction[.id]),
|
|
|
|
|
\(interaction[.variant]),
|
|
|
|
|
\(interaction[.timestampMs]),
|
|
|
|
|
\(interaction[.receivedAtTimestampMs]),
|
|
|
|
|
\(interaction[.authorId]),
|
|
|
|
|
IFNULL(\(profile[.nickname]), \(profile[.name])) AS \(ViewModel.authorNameInternalKey),
|
|
|
|
|
\(interaction[.body]),
|
|
|
|
|