Set visible ranges on the home screen sliding sync view (#342)

* Set visible ranges on the home screen sliding sync view
* Prevent the visible items from being updated while in search mode
* Enable diffs on invalidations as they seem to fix duplicated events in the home screen room list
* Promoted some diffing logs to info from verbose
This commit is contained in:
Stefan Ceriu
2022-11-25 17:50:43 +02:00
committed by GitHub
parent 1781f92882
commit 00cd2ab707
14 changed files with 271 additions and 88 deletions
@@ -115,6 +115,8 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
callback?(.verifySession)
case .skipSessionVerification:
state.showSessionVerificationBanner = false
case .updatedVisibleItemIdentifiers(let identifiers):
updateVisibleRange(visibleItemIdentifiers: identifiers)
}
}
@@ -189,4 +191,20 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
state.rooms = rooms
roomsForIdentifiers = newRoomsForIdentifiers
}
private func updateVisibleRange(visibleItemIdentifiers items: Set<String>) {
let result = items.compactMap { itemIdentifier in
state.rooms.firstIndex { $0.id == itemIdentifier }
}.sorted()
guard !result.isEmpty else {
return
}
guard let lowerBound = result.first, let upperBound = result.last else {
return
}
userSession.clientProxy.roomSummaryProvider?.updateVisibleRange(lowerBound...upperBound)
}
}