New SlidingSync flow (#373)

* Switch back to using slidingSync rooms for timeline listeners

* Expose 2 types of slidingSync views from the clientProxy and combine their results for the roomList

* Fix breaking api changes

* Remove sender mxids from the room list (until rust provides resolved display names)

* Bump RustSDK to v1.0.22-alpha

* Rename originServerTs to timestamp throughout

* Simplified sliding sync view list merging

* Rollback some SS changes as things still don't work properly

* Revert "Switch back to using slidingSync rooms for timeline listeners"

This reverts commit 1d6a6c09d8ddf386edefbe0ac6beaf52cc333fba.
This commit is contained in:
Stefan Ceriu
2022-12-16 14:05:08 +02:00
committed by GitHub
parent 6f974a4422
commit ab10278ff5
13 changed files with 119 additions and 76 deletions
@@ -58,7 +58,9 @@ class ClientProxy: ClientProxyProtocol {
private var slidingSyncObserverToken: StoppableSpawn?
private var slidingSync: SlidingSync?
var roomSummaryProvider: RoomSummaryProviderProtocol?
var visibleRoomsSummaryProvider: RoomSummaryProviderProtocol?
var allRoomsSummaryProvider: RoomSummaryProviderProtocol?
deinit {
// These need to be inlined instead of using stopSync()
@@ -83,25 +85,40 @@ class ClientProxy: ClientProxyProtocol {
do {
let slidingSyncBuilder = try client.slidingSync().homeserver(url: ServiceLocator.shared.settings.slidingSyncProxyBaseURLString)
let slidingSyncView = try SlidingSyncViewBuilder()
let visibleRoomsView = try SlidingSyncViewBuilder()
.timelineLimit(limit: 10)
.requiredState(requiredState: [RequiredState(key: "m.room.avatar", value: ""),
RequiredState(key: "m.room.encryption", value: "")])
.name(name: "HomeScreenView")
.name(name: "CurrentlyVisibleRooms")
.syncMode(mode: .selective)
.addRange(from: 0, to: 20)
.build()
let allRoomsView = try SlidingSyncViewBuilder()
.noTimelineLimit()
.requiredState(requiredState: [RequiredState(key: "m.room.avatar", value: ""),
RequiredState(key: "m.room.encryption", value: "")])
.name(name: "AllRooms")
.syncMode(mode: .growingFullSync)
.batchSize(batchSize: 20)
.build()
let slidingSync = try slidingSyncBuilder
.addView(v: slidingSyncView)
.addView(v: visibleRoomsView)
// .addView(v: allRoomsView) // FIXME: Intentionally disabled as it doesn't work properly
.withCommonExtensions()
.coldCache(name: "ElementX")
.build()
let slidingSyncViewProxy = SlidingSyncViewProxy(clientProxy: self, slidingSync: slidingSync, slidingSyncView: slidingSyncView)
let visibleRoomsViewProxy = SlidingSyncViewProxy(clientProxy: self, slidingSync: slidingSync, slidingSyncView: visibleRoomsView)
self.roomSummaryProvider = RoomSummaryProvider(slidingSyncViewProxy: slidingSyncViewProxy,
roomMessageFactory: RoomMessageFactory())
let allRoomsViewProxy = SlidingSyncViewProxy(clientProxy: self, slidingSync: slidingSync, slidingSyncView: allRoomsView)
self.visibleRoomsSummaryProvider = RoomSummaryProvider(slidingSyncViewProxy: visibleRoomsViewProxy,
roomMessageFactory: RoomMessageFactory())
self.allRoomsSummaryProvider = RoomSummaryProvider(slidingSyncViewProxy: allRoomsViewProxy,
roomMessageFactory: RoomMessageFactory())
self.slidingSync = slidingSync
} catch {
@@ -286,7 +303,8 @@ class ClientProxy: ClientProxyProtocol {
}
fileprivate func didReceiveSlidingSyncUpdate(summary: UpdateSummary) {
roomSummaryProvider?.updateRoomsWithIdentifiers(summary.rooms)
visibleRoomsSummaryProvider?.updateRoomsWithIdentifiers(summary.rooms)
allRoomsSummaryProvider?.updateRoomsWithIdentifiers(summary.rooms)
callbacks.send(.receivedSyncUpdate)
}
@@ -71,7 +71,9 @@ protocol ClientProxyProtocol: AnyObject, MediaProxyProtocol {
var restorationToken: RestorationToken? { get }
var roomSummaryProvider: RoomSummaryProviderProtocol? { get }
var visibleRoomsSummaryProvider: RoomSummaryProviderProtocol? { get }
var allRoomsSummaryProvider: RoomSummaryProviderProtocol? { get }
func startSync()
@@ -27,11 +27,13 @@ class MockClientProxy: ClientProxyProtocol {
let homeserver = ""
let restorationToken: RestorationToken? = nil
var roomSummaryProvider: RoomSummaryProviderProtocol? = MockRoomSummaryProvider()
var visibleRoomsSummaryProvider: RoomSummaryProviderProtocol? = MockRoomSummaryProvider()
var allRoomsSummaryProvider: RoomSummaryProviderProtocol? = MockRoomSummaryProvider()
internal init(userIdentifier: String, roomSummaryProvider: RoomSummaryProviderProtocol? = MockRoomSummaryProvider()) {
self.userIdentifier = userIdentifier
self.roomSummaryProvider = roomSummaryProvider
visibleRoomsSummaryProvider = roomSummaryProvider
}
func startSync() { }