mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Show the last message state in the room list.
This commit is contained in:
@@ -29,6 +29,8 @@ struct RoomSummary {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum LastMessageState { case sending, failed }
|
||||
|
||||
let room: Room
|
||||
|
||||
@@ -46,6 +48,7 @@ struct RoomSummary {
|
||||
|
||||
let lastMessage: AttributedString?
|
||||
let lastMessageDate: Date?
|
||||
let lastMessageState: LastMessageState?
|
||||
let unreadMessagesCount: UInt
|
||||
let unreadMentionsCount: UInt
|
||||
let unreadNotificationsCount: UInt
|
||||
@@ -117,6 +120,7 @@ extension RoomSummary {
|
||||
|
||||
lastMessage = AttributedString(string)
|
||||
lastMessageDate = .mock
|
||||
lastMessageState = nil
|
||||
unreadMessagesCount = hasUnreadMessages ? 1 : 0
|
||||
unreadMentionsCount = hasUnreadMentions ? 1 : 0
|
||||
unreadNotificationsCount = hasUnreadNotifications ? 1 : 0
|
||||
|
||||
@@ -261,13 +261,15 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
|
||||
var attributedLastMessage: AttributedString?
|
||||
var lastMessageDate: Date?
|
||||
var lastMessageState: RoomSummary.LastMessageState?
|
||||
|
||||
if let latestRoomMessage = roomDetails.latestEvent {
|
||||
switch latestRoomMessage {
|
||||
case .local(let timestamp, let senderID, let profile, let content, _):
|
||||
case .local(let timestamp, let senderID, let profile, let content, let isSending):
|
||||
let sender = TimelineItemSender(senderID: senderID, senderProfile: profile)
|
||||
attributedLastMessage = eventStringBuilder.buildAttributedString(for: content, sender: sender, isOutgoing: true)
|
||||
lastMessageDate = Date(timeIntervalSince1970: TimeInterval(timestamp / 1000))
|
||||
lastMessageState = isSending ? .sending : .failed // No need to worry about sent for .local: https://github.com/matrix-org/matrix-rust-sdk/issues/3941
|
||||
case .remote(let timestamp, let senderID, let isOwn, let profile, let content):
|
||||
let sender = TimelineItemSender(senderID: senderID, senderProfile: profile)
|
||||
attributedLastMessage = eventStringBuilder.buildAttributedString(for: content, sender: sender, isOutgoing: isOwn)
|
||||
@@ -301,6 +303,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
activeMembersCount: UInt(roomInfo.activeMembersCount),
|
||||
lastMessage: attributedLastMessage,
|
||||
lastMessageDate: lastMessageDate,
|
||||
lastMessageState: lastMessageState,
|
||||
unreadMessagesCount: UInt(roomInfo.numUnreadMessages),
|
||||
unreadMentionsCount: UInt(roomInfo.numUnreadMentions),
|
||||
unreadNotificationsCount: UInt(roomInfo.numUnreadNotifications),
|
||||
|
||||
Reference in New Issue
Block a user