mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 15:45:11 +00:00
Various sliding sync tweaks (#446)
* Refactor SS configuration and add (unfinished) support for adding views dynamically. * Implement pop and clear support on the room summary provider * Register views against sliding sync * Read invalidated vislbeRoomsSummaryProvider from the allRoomSummaryProvider * Switch SS window range setting from the ScrollViewAdapter to a publisher debounce * Tweak allRoomsView addition: switch from listening the visibleRoomsView's state to when it publishes the first diff update * Cleanup client delegate and sliding sync observers and lifecycle * Bump the RustSDK to 1.0.30-alpha * Reuse startSync within restartSync
This commit is contained in:
@@ -46,7 +46,7 @@ class MockRoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
|
||||
func updateRoomsWithIdentifiers(_ identifiers: [String]) { }
|
||||
|
||||
func updateVisibleRange(_ range: ClosedRange<Int>) { }
|
||||
func updateVisibleRange(_ range: Range<Int>) { }
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func updateVisibleRange(_ range: ClosedRange<Int>) {
|
||||
func updateVisibleRange(_ range: Range<Int>) {
|
||||
slidingSyncViewProxy.updateVisibleRange(range)
|
||||
}
|
||||
|
||||
@@ -181,6 +181,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
// swiftlint:disable:next cyclomatic_complexity
|
||||
private func buildDiff(from diff: SlidingSyncViewRoomsListDiff, on rooms: [RoomSummary]) -> CollectionDifference<RoomSummary>? {
|
||||
var changes = [CollectionDifference<RoomSummary>.Change]()
|
||||
|
||||
@@ -216,6 +217,18 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
for (index, value) in values.enumerated() {
|
||||
changes.append(.insert(offset: index, element: buildSummaryForRoomListEntry(value), associatedWith: nil))
|
||||
}
|
||||
case .clear:
|
||||
MXLog.verbose("Clear all items, current total count: \(rooms.count)")
|
||||
for (index, value) in rooms.enumerated() {
|
||||
changes.append(.remove(offset: index, element: value, associatedWith: nil))
|
||||
}
|
||||
case .pop:
|
||||
MXLog.verbose("Pop, current total count: \(rooms.count)")
|
||||
guard let value = rooms.last else {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
changes.append(.remove(offset: rooms.count - 1, element: value, associatedWith: nil))
|
||||
}
|
||||
|
||||
return CollectionDifference(changes)
|
||||
|
||||
@@ -55,5 +55,5 @@ protocol RoomSummaryProviderProtocol {
|
||||
/// - Parameter identifiers: the identifiers for the rooms that have changed
|
||||
func updateRoomsWithIdentifiers(_ identifiers: [String])
|
||||
|
||||
func updateVisibleRange(_ range: ClosedRange<Int>)
|
||||
func updateVisibleRange(_ range: Range<Int>)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user