Room list fixes (#431)

* Fixes #396 - Avoid duplicates in room list, cleanup logic throughout

* Re-enabled the allRoomsView with a hard 500 room limit and reduced the diffing collection time.

* Fixes #385, #411 - Filter out spaces, invites and tombstoned rooms from the room list

* Various tweaks following code review
This commit is contained in:
Stefan Ceriu
2023-01-10 17:34:42 +02:00
committed by GitHub
parent edc06bf662
commit 3d1266ca25
9 changed files with 151 additions and 107 deletions
@@ -24,7 +24,9 @@ struct HomeScreenRoomCell: View {
var body: some View {
Button {
context.send(viewAction: .selectRoom(roomIdentifier: room.id))
if let roomId = room.roomId {
context.send(viewAction: .selectRoom(roomIdentifier: roomId))
}
} label: {
HStack(spacing: 16.0) {
if let avatar = room.avatar {
@@ -35,7 +37,7 @@ struct HomeScreenRoomCell: View {
.clipShape(Circle())
.accessibilityHidden(true)
} else {
PlaceholderAvatarImage(text: room.name, contentId: room.id)
PlaceholderAvatarImage(text: room.name, contentId: room.roomId)
.clipShape(Circle())
.frame(width: avatarSize, height: avatarSize)
.accessibilityHidden(true)
@@ -86,7 +88,9 @@ struct HomeScreenRoomCell: View {
.frame(minHeight: 64.0)
.accessibilityElement(children: .combine)
.task {
context.send(viewAction: .loadRoomData(roomIdentifier: room.id))
if let roomId = room.roomId {
context.send(viewAction: .loadRoomData(roomIdentifier: roomId))
}
}
}
.accessibilityIdentifier("roomName:\(room.name)")
@@ -113,27 +117,29 @@ struct HomeScreenRoomCell_Previews: PreviewProvider {
static var previews: some View {
body.tint(.element.accent)
}
static var body: some View {
let summaryProvider = MockRoomSummaryProvider(state: .loaded)
let userSession = MockUserSession(clientProxy: MockClientProxy(userIdentifier: "John Doe", roomSummaryProvider: summaryProvider),
mediaProvider: MockMediaProvider())
let viewModel = HomeScreenViewModel(userSession: userSession,
attributedStringBuilder: AttributedStringBuilder())
let rooms: [HomeScreenRoom] = summaryProvider.roomListPublisher.value.compactMap { summary in
guard let summary = summary.asFilled else {
let rooms: [HomeScreenRoom] = summaryProvider.roomListPublisher.value.compactMap { summary -> HomeScreenRoom? in
switch summary {
case .empty:
return nil
case .filled(let details), .invalidated(let details):
return HomeScreenRoom(id: UUID().uuidString,
roomId: details.id,
name: details.name,
hasUnreads: details.unreadNotificationCount > 0,
timestamp: Date.now.formatted(date: .omitted, time: .shortened))
}
return HomeScreenRoom(id: summary.id,
name: summary.name,
hasUnreads: summary.unreadNotificationCount > 0,
timestamp: Date.now.formatted(date: .omitted, time: .shortened))
}
return VStack {
ForEach(rooms) { room in
HomeScreenRoomCell(room: room, context: viewModel.context)