mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Move last message timestamp formatting to the room summary provider and its background processing queue
This commit is contained in:
committed by
Stefan Ceriu
parent
1433100535
commit
413b433806
@@ -53,21 +53,21 @@ class MockRoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
isDirect: true,
|
||||
avatarURL: nil,
|
||||
lastMessage: AttributedString("Prosciutto beef ribs pancetta filet mignon kevin hamburger, chuck ham venison picanha. Beef ribs chislic turkey biltong tenderloin."),
|
||||
lastMessageTimestamp: .distantPast,
|
||||
lastMessageFormattedTimestamp: "Now",
|
||||
unreadNotificationCount: 4)),
|
||||
.filled(details: RoomSummaryDetails(id: "2",
|
||||
name: "Second room",
|
||||
isDirect: true,
|
||||
avatarURL: URL.picturesDirectory,
|
||||
lastMessage: nil,
|
||||
lastMessageTimestamp: nil,
|
||||
lastMessageFormattedTimestamp: nil,
|
||||
unreadNotificationCount: 1)),
|
||||
.filled(details: RoomSummaryDetails(id: "3",
|
||||
name: "Third room",
|
||||
isDirect: true,
|
||||
avatarURL: nil,
|
||||
lastMessage: try? AttributedString(markdown: "**@mock:client.com**: T-bone beef ribs bacon"),
|
||||
lastMessageTimestamp: .distantPast,
|
||||
lastMessageFormattedTimestamp: "Later",
|
||||
unreadNotificationCount: 0)),
|
||||
.empty
|
||||
]
|
||||
|
||||
@@ -22,7 +22,7 @@ struct RoomSummaryDetails {
|
||||
let isDirect: Bool
|
||||
let avatarURL: URL?
|
||||
let lastMessage: AttributedString?
|
||||
let lastMessageTimestamp: Date?
|
||||
let lastMessageFormattedTimestamp: String?
|
||||
let unreadNotificationCount: UInt
|
||||
}
|
||||
|
||||
|
||||
@@ -97,14 +97,14 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
}
|
||||
|
||||
var attributedLastMessage: AttributedString?
|
||||
var lastMessageTimestamp: Date?
|
||||
var lastMessageFormattedTimestamp: String?
|
||||
|
||||
// Dispatch onto another queue otherwise the rust method latestRoomMessage crashes.
|
||||
// This will be fixed when we get async uniffi support.
|
||||
DispatchQueue.global(qos: .default).sync {
|
||||
if let latestRoomMessage = room.latestRoomMessage() {
|
||||
let lastMessage = EventTimelineItemProxy(item: latestRoomMessage)
|
||||
lastMessageTimestamp = lastMessage.timestamp
|
||||
lastMessageFormattedTimestamp = lastMessage.timestamp.formattedMinimal()
|
||||
attributedLastMessage = eventStringBuilder.buildAttributedString(for: lastMessage)
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
isDirect: room.isDm() ?? false,
|
||||
avatarURL: avatarURL,
|
||||
lastMessage: attributedLastMessage,
|
||||
lastMessageTimestamp: lastMessageTimestamp,
|
||||
lastMessageFormattedTimestamp: lastMessageFormattedTimestamp,
|
||||
unreadNotificationCount: UInt(room.unreadNotifications().notificationCount()))
|
||||
|
||||
return invalidated ? .invalidated(details: details) : .filled(details: details)
|
||||
|
||||
Reference in New Issue
Block a user