Replace old visible rooms range with subscriptions in the room list. (#3014)

* Add a SubscriptionTracker actor to RoomProxy.

* Request subscriptions when scrolling rooms.

* Stop unsubscribing in preparation for Simplified Sliding Sync.
This commit is contained in:
Doug
2024-07-08 14:32:13 +01:00
committed by GitHub
parent bf9e1d614f
commit a1329d9d54
6 changed files with 31 additions and 58 deletions
@@ -58,7 +58,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
/// Build a new summary provider with the given parameters
/// - Parameters:
/// - shouldUpdateVisibleRange: whether this summary provider should foward visible ranges
/// - shouldUpdateVisibleRange: whether this summary provider should forward visible ranges
/// to the room list service through the `applyInput(input: .viewport(ranges` api. Only useful for
/// lists that need to update the visible range on Sliding Sync
init(roomListService: RoomListServiceProtocol,
@@ -124,6 +124,25 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
guard shouldUpdateVisibleRange else {
return
}
// The scroll view content size based visible range calculations might create large ranges
// This is just a safety check to not overload the backend
var range = range
if range.upperBound - range.lowerBound > SlidingSyncConstants.maximumVisibleRangeSize {
let upperBound = range.lowerBound + SlidingSyncConstants.maximumVisibleRangeSize
range = range.lowerBound..<upperBound
}
MXLog.info("\(name): Requesting subscriptions for visible range: \(range)")
for index in range {
guard index < rooms.count else { return }
// Note, we must use the item received by the diff. Asking the roomListService to get
// a new item instance will result in /sync being called when already subscribed.
rooms[index].roomListItem.subscribe(settings: .init(requiredState: SlidingSyncConstants.defaultRequiredState,
timelineLimit: SlidingSyncConstants.defaultTimelineLimit,
includeHeroes: false))
}
}
func setFilter(_ filter: RoomSummaryProviderFilter) {