From b839273ce0bcb02fe71630f17bde070ddcf95716 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Thu, 12 Sep 2024 14:36:47 +0200 Subject: [PATCH] fix: also lazy load members for archive This should speed up loading the archived rooms. One of the reasons it was so slow, is because we were loading all room members! Additionally this may work around a bug in Synapse, where rooms stuck in their partial state may block sync indefinitely. Relates to https://github.com/famedly/product-management/issues/2250 --- lib/fake_matrix_api.dart | 2 +- lib/src/client.dart | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/fake_matrix_api.dart b/lib/fake_matrix_api.dart index cb89faad..c78d1aae 100644 --- a/lib/fake_matrix_api.dart +++ b/lib/fake_matrix_api.dart @@ -1972,7 +1972,7 @@ class FakeMatrixApi extends BaseClient { ] } }, - '/client/v3/sync?filter=%7B%22room%22%3A%7B%22include_leave%22%3Atrue%2C%22timeline%22%3A%7B%22limit%22%3A10%7D%7D%7D&timeout=0': + '/client/v3/sync?filter=%7B%22room%22%3A%7B%22include_leave%22%3Atrue%2C%22state%22%3A%7B%22lazy_load_members%22%3Atrue%7D%2C%22timeline%22%3A%7B%22limit%22%3A10%7D%7D%7D&timeout=0': (var req) => archiveSyncResponse, '/client/v3/sync?filter=1234&timeout=0': (var req) => syncResponse, '/client/v3/sync?filter=1234&since=1234&full_state=false&set_presence=unavailable&timeout=15': diff --git a/lib/src/client.dart b/lib/src/client.dart index 77fbb5f5..d842fe5d 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -1109,8 +1109,17 @@ class Client extends MatrixApi { /// [ArchivedRoom] objects containing the [Room] and the associated [Timeline]. Future> loadArchiveWithTimeline() async { _archivedRooms.clear(); + + final filter = jsonEncode(Filter( + room: RoomFilter( + state: StateFilter(lazyLoadMembers: true), + includeLeave: true, + timeline: StateFilter(limit: 10), + ), + ).toJson()); + final syncResp = await sync( - filter: '{"room":{"include_leave":true,"timeline":{"limit":10}}}', + filter: filter, timeout: _archiveCacheBusterTimeout, setPresence: syncPresence, );