#93: Add a sync limit of 20 and prefill rooms when loading the last message.

Update the SDK to 1.0.13-alpha.
This commit is contained in:
Doug
2022-07-28 12:46:48 +01:00
committed by GitHub
parent c20bc6bd1c
commit 87b2a41a69
8 changed files with 16 additions and 7 deletions
+1 -1
View File
@@ -2707,7 +2707,7 @@
repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift"; repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift";
requirement = { requirement = {
kind = exactVersion; kind = exactVersion;
version = "1.0.12-alpha"; version = "1.0.13-alpha";
}; };
}; };
9A472EE0218FE7DCF5283429 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = { 9A472EE0218FE7DCF5283429 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = {
@@ -68,8 +68,8 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://github.com/matrix-org/matrix-rust-components-swift", "location" : "https://github.com/matrix-org/matrix-rust-components-swift",
"state" : { "state" : {
"revision" : "3dbb1533d1c27dcd311a8c9751de7c020ccf2d8c", "revision" : "1358c9c2a85cfb5fc1bfadce13565e02618725d4",
"version" : "1.0.12-alpha" "version" : "1.0.13-alpha"
} }
}, },
{ {
@@ -119,7 +119,7 @@ final class HomeScreenCoordinator: Coordinator, Presentable {
func updateRoomsList() { func updateRoomsList() {
roomSummaries = parameters.userSession.clientProxy.rooms.compactMap { roomProxy in roomSummaries = parameters.userSession.clientProxy.rooms.compactMap { roomProxy in
guard !roomProxy.isSpace, !roomProxy.isTombstoned else { guard roomProxy.isJoined, !roomProxy.isSpace, !roomProxy.isTombstoned else {
return nil return nil
} }
@@ -24,6 +24,9 @@ private class WeakClientProxyWrapper: ClientDelegate {
} }
class ClientProxy: ClientProxyProtocol { class ClientProxy: ClientProxyProtocol {
/// The maximum number of timeline events required during a sync request.
static let syncLimit: UInt16 = 20
private let client: Client private let client: Client
private let backgroundTaskService: BackgroundTaskServiceProtocol private let backgroundTaskService: BackgroundTaskServiceProtocol
private var sessionVerificationControllerProxy: SessionVerificationControllerProxy? private var sessionVerificationControllerProxy: SessionVerificationControllerProxy?
@@ -48,7 +51,7 @@ class ClientProxy: ClientProxyProtocol {
client.setDelegate(delegate: WeakClientProxyWrapper(clientProxy: self)) client.setDelegate(delegate: WeakClientProxyWrapper(clientProxy: self))
Benchmark.startTrackingForIdentifier("ClientSync", message: "Started sync.") Benchmark.startTrackingForIdentifier("ClientSync", message: "Started sync.")
client.startSync() client.startSync(timelineLimit: ClientProxy.syncLimit)
Task { await updateRooms() } Task { await updateRooms() }
} }
@@ -67,6 +67,10 @@ class RoomProxy: RoomProxyProtocol {
room.topic() room.topic()
} }
var isJoined: Bool {
room.membership() == .joined
}
var isDirect: Bool { var isDirect: Bool {
room.isDirect() room.isDirect()
} }
@@ -141,7 +141,8 @@ class RoomSummary: RoomSummaryProtocol {
return return
} }
switch await roomProxy.paginateBackwards(count: 1) { // Pre-fill the room with some messages and use the last message in the response.
switch await roomProxy.paginateBackwards(count: UInt(ClientProxy.syncLimit)) {
case .success: case .success:
lastMessage = await eventBriefFactory.buildEventBriefFor(message: roomProxy.messages.last) lastMessage = await eventBriefFactory.buildEventBriefFor(message: roomProxy.messages.last)
case .failure(let error): case .failure(let error):
+1
View File
@@ -0,0 +1 @@
Add a sync limit of 20 timeline items and prefill rooms with this number of events when calculating the last message.
+1 -1
View File
@@ -31,7 +31,7 @@ include:
packages: packages:
MatrixRustSDK: MatrixRustSDK:
url: https://github.com/matrix-org/matrix-rust-components-swift url: https://github.com/matrix-org/matrix-rust-components-swift
exactVersion: 1.0.12-alpha exactVersion: 1.0.13-alpha
# path: ../matrix-rust-components-swift # path: ../matrix-rust-components-swift
DesignKit: DesignKit:
path: ./ path: ./