mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Use local room list sorting from Rust. (#2978)
* Switch to the new local room list sorting API * Get rid of the RoomSummary enum, replace it by the inner RoomSummaryDetails * And finally, rename RoomSummaryDetails to RoomSummary * Fix a bunch of warnings * Small tidy up post rebase/review. - Remove unused invalidated property. - Rename some RoomSummary instances to summary instead of details. - Fix tests with missing roomListItem's. * Update snapshots --------- Co-authored-by: Doug <douglase@element.io>
This commit is contained in:
@@ -152,8 +152,7 @@ struct HomeScreenRoom: Identifiable, Equatable {
|
||||
|
||||
static let placeholderLastMessage = AttributedString("Hidden last message")
|
||||
|
||||
/// The list item identifier can be a real room identifier, a custom one for invalidated entries
|
||||
/// or a completely unique one for empty items and skeletons
|
||||
/// The list item identifier is it's room identifier.
|
||||
let id: String
|
||||
|
||||
/// The real room identifier this item points to
|
||||
@@ -205,39 +204,39 @@ struct HomeScreenRoom: Identifiable, Equatable {
|
||||
}
|
||||
|
||||
extension HomeScreenRoom {
|
||||
init(details: RoomSummaryDetails, invalidated: Bool, hideUnreadMessagesBadge: Bool) {
|
||||
let identifier = invalidated ? "invalidated-" + details.id : details.id
|
||||
init(summary: RoomSummary, hideUnreadMessagesBadge: Bool) {
|
||||
let identifier = summary.id
|
||||
|
||||
let hasUnreadMessages = hideUnreadMessagesBadge ? false : details.hasUnreadMessages
|
||||
let hasUnreadMessages = hideUnreadMessagesBadge ? false : summary.hasUnreadMessages
|
||||
|
||||
let isDotShown = hasUnreadMessages || details.hasUnreadMentions || details.hasUnreadNotifications || details.isMarkedUnread
|
||||
let isMentionShown = details.hasUnreadMentions && !details.isMuted
|
||||
let isMuteShown = details.isMuted
|
||||
let isCallShown = details.hasOngoingCall
|
||||
let isHighlighted = details.isMarkedUnread || (!details.isMuted && (details.hasUnreadNotifications || details.hasUnreadMentions))
|
||||
let isDotShown = hasUnreadMessages || summary.hasUnreadMentions || summary.hasUnreadNotifications || summary.isMarkedUnread
|
||||
let isMentionShown = summary.hasUnreadMentions && !summary.isMuted
|
||||
let isMuteShown = summary.isMuted
|
||||
let isCallShown = summary.hasOngoingCall
|
||||
let isHighlighted = summary.isMarkedUnread || (!summary.isMuted && (summary.hasUnreadNotifications || summary.hasUnreadMentions))
|
||||
|
||||
var inviter: InviterDetails?
|
||||
if let roomMemberProxy = details.inviter {
|
||||
if let roomMemberProxy = summary.inviter {
|
||||
inviter = .init(userID: roomMemberProxy.userID,
|
||||
displayName: roomMemberProxy.displayName,
|
||||
avatarURL: roomMemberProxy.avatarURL)
|
||||
}
|
||||
|
||||
self.init(id: identifier,
|
||||
roomID: details.id,
|
||||
type: details.isInvite ? .invite : .room,
|
||||
roomID: summary.id,
|
||||
type: summary.isInvite ? .invite : .room,
|
||||
badges: .init(isDotShown: isDotShown,
|
||||
isMentionShown: isMentionShown,
|
||||
isMuteShown: isMuteShown,
|
||||
isCallShown: isCallShown),
|
||||
name: details.name,
|
||||
isDirect: details.isDirect,
|
||||
name: summary.name,
|
||||
isDirect: summary.isDirect,
|
||||
isHighlighted: isHighlighted,
|
||||
isFavourite: details.isFavourite,
|
||||
timestamp: details.lastMessageFormattedTimestamp,
|
||||
lastMessage: details.lastMessage,
|
||||
avatar: details.avatar,
|
||||
isFavourite: summary.isFavourite,
|
||||
timestamp: summary.lastMessageFormattedTimestamp,
|
||||
lastMessage: summary.lastMessage,
|
||||
avatar: summary.avatar,
|
||||
inviter: inviter,
|
||||
canonicalAlias: details.canonicalAlias)
|
||||
canonicalAlias: summary.canonicalAlias)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user