Drop the entire sliding sync observer and updating rooms by identifiers now that we can request to be sent item updates

This commit is contained in:
Stefan Ceriu
2023-01-26 09:38:12 +02:00
committed by Stefan Ceriu
parent bd4c0b72cb
commit b68002cbb4
6 changed files with 7 additions and 81 deletions
@@ -19,7 +19,7 @@ import Foundation
import MatrixRustSDK
import UIKit
private class WeakClientProxyWrapper: ClientDelegate, SlidingSyncObserver {
private class WeakClientProxyWrapper: ClientDelegate {
private weak var clientProxy: ClientProxy?
init(clientProxy: ClientProxy) {
@@ -39,17 +39,6 @@ private class WeakClientProxyWrapper: ClientDelegate, SlidingSyncObserver {
MXLog.info("Did update restoration token")
clientProxy?.didUpdateRestoreToken()
}
// MARK: - SlidingSyncDelegate
func didReceiveSyncUpdate(summary: UpdateSummary) {
if summary.views.isEmpty, summary.rooms.isEmpty {
return
}
MXLog.info("Received sliding sync update")
clientProxy?.didReceiveSlidingSyncUpdate(summary: summary)
}
}
class ClientProxy: ClientProxyProtocol {
@@ -269,6 +258,7 @@ class ClientProxy: ClientProxyProtocol {
.name(name: "CurrentlyVisibleRooms")
.syncMode(mode: .selective)
.addRange(from: 0, to: 20)
.sendUpdatesForItems(enable: true)
.build()
let slidingSync = try slidingSyncBuilder
@@ -277,8 +267,6 @@ class ClientProxy: ClientProxyProtocol {
.coldCache(name: "ElementX")
.build()
slidingSync.setObserver(observer: WeakClientProxyWrapper(clientProxy: self))
self.slidingSync = slidingSync
buildAndConfigureVisibleRoomsSlidingSyncView(slidingSync: slidingSync, visibleRoomsView: visibleRoomsView)
@@ -324,6 +312,7 @@ class ClientProxy: ClientProxyProtocol {
.syncMode(mode: .growingFullSync)
.batchSize(batchSize: 100)
.roomLimit(limit: 500)
.sendUpdatesForItems(enable: true)
.build()
let allRoomsViewProxy = SlidingSyncViewProxy(slidingSync: slidingSync, slidingSyncView: allRoomsView)
@@ -382,13 +371,6 @@ class ClientProxy: ClientProxyProtocol {
callbacks.send(.updatedRestoreToken)
}
fileprivate func didReceiveSlidingSyncUpdate(summary: UpdateSummary) {
visibleRoomsSummaryProvider?.updateRoomsWithIdentifiers(summary.rooms)
allRoomsSummaryProvider?.updateRoomsWithIdentifiers(summary.rooms)
callbacks.send(.receivedSyncUpdate)
}
/// Convenience method to get the json string of an Encodable
private func jsonString(from dictionary: [AnyHashable: Any]?) -> String? {
guard let dictionary,