mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 19:44:05 +00:00
Add back custom identifiers for invalidated room, avoid duplicates and gaps on the room list
This commit is contained in:
committed by
Stefan Ceriu
parent
ee643f7a69
commit
d120a53ebd
@@ -215,8 +215,11 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
switch summary {
|
||||
case .empty:
|
||||
rooms.append(HomeScreenRoom.placeholder())
|
||||
case .invalidated(let details):
|
||||
let room = buildRoom(with: details, invalidated: true)
|
||||
rooms.append(room)
|
||||
case .filled(let details):
|
||||
let room = buildRoom(with: details)
|
||||
let room = buildRoom(with: details, invalidated: false)
|
||||
rooms.append(room)
|
||||
}
|
||||
}
|
||||
@@ -226,14 +229,16 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
MXLog.info("Finished updating rooms")
|
||||
}
|
||||
|
||||
private func buildRoom(with details: RoomSummaryDetails) -> HomeScreenRoom {
|
||||
HomeScreenRoom(id: details.id,
|
||||
roomId: details.id,
|
||||
name: details.name,
|
||||
hasUnreads: details.unreadNotificationCount > 0,
|
||||
timestamp: details.lastMessageFormattedTimestamp,
|
||||
lastMessage: .init(attributedString: details.lastMessage, isLoading: false),
|
||||
avatarURL: details.avatarURL)
|
||||
private func buildRoom(with details: RoomSummaryDetails, invalidated: Bool) -> HomeScreenRoom {
|
||||
let identifier = invalidated ? "invalidated-" + details.id : details.id
|
||||
|
||||
return HomeScreenRoom(id: identifier,
|
||||
roomId: details.id,
|
||||
name: details.name,
|
||||
hasUnreads: details.unreadNotificationCount > 0,
|
||||
timestamp: details.lastMessageFormattedTimestamp,
|
||||
lastMessage: .init(attributedString: details.lastMessage, isLoading: false),
|
||||
avatarURL: details.avatarURL)
|
||||
}
|
||||
|
||||
private func updateVisibleRange(_ range: Range<Int>) {
|
||||
|
||||
@@ -177,7 +177,7 @@ struct HomeScreenRoomCell_Previews: PreviewProvider {
|
||||
switch summary {
|
||||
case .empty:
|
||||
return nil
|
||||
case .filled(let details):
|
||||
case .invalidated(let details), .filled(let details):
|
||||
return HomeScreenRoom(id: UUID().uuidString,
|
||||
roomId: details.id,
|
||||
name: details.name,
|
||||
|
||||
Reference in New Issue
Block a user