Show the last message state in the room list.

This commit is contained in:
Doug
2025-11-27 13:33:28 +00:00
committed by Doug
parent dc8f5ef5a9
commit 62930968f8
18 changed files with 129 additions and 15 deletions
@@ -197,6 +197,9 @@ struct HomeScreenRoom: Identifiable, Equatable {
let lastMessage: AttributedString?
enum LastMessageState { case sending, failed }
let lastMessageState: LastMessageState?
let avatar: RoomAvatar
let canonicalAlias: String?
@@ -204,11 +207,13 @@ struct HomeScreenRoom: Identifiable, Equatable {
let isTombstoned: Bool
var displayedLastMessage: AttributedString? {
// If the room is tombstoned, show a specific message, regardless of any last message.
guard !isTombstoned else {
return AttributedString(L10n.screenRoomlistTombstonedRoomDescription)
if isTombstoned {
AttributedString(L10n.screenRoomlistTombstonedRoomDescription)
} else if lastMessageState == .failed {
AttributedString(L10n.commonMessageFailedToSend)
} else {
lastMessage
}
return lastMessage
}
static func placeholder() -> HomeScreenRoom {
@@ -222,6 +227,7 @@ struct HomeScreenRoom: Identifiable, Equatable {
isFavourite: false,
timestamp: "Now",
lastMessage: placeholderLastMessage,
lastMessageState: nil,
avatar: .room(id: "", name: "", avatarURL: nil),
canonicalAlias: nil,
isTombstoned: false)
@@ -260,8 +266,23 @@ extension HomeScreenRoom {
isFavourite: summary.isFavourite,
timestamp: summary.lastMessageDate?.formattedMinimal(),
lastMessage: summary.lastMessage,
lastMessageState: summary.homeScreenLastMessageState,
avatar: summary.avatar,
canonicalAlias: summary.canonicalAlias,
isTombstoned: summary.isTombstoned)
}
}
private extension RoomSummary {
var homeScreenLastMessageState: HomeScreenRoom.LastMessageState? {
if isTombstoned {
nil
} else {
switch lastMessageState {
case .sending: .sending
case .failed: .failed
case .none: .none
}
}
}
}