From e1343e9c837fdf1f31b8ff5815c2f04291e21cb5 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Wed, 25 Aug 2021 10:37:01 +0200 Subject: [PATCH] fix: requestHistory() for archived rooms Using JoinedRoomUpdate() in a fake sync for archived rooms when requesting the history leads to the problem that the room is stored as a joined room in the store which is wrong. --- lib/src/room.dart | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/src/room.dart b/lib/src/room.dart index 2284f5de..cf03db34 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -959,12 +959,22 @@ class Room { await client.handleSync( SyncUpdate(nextBatch: '') ..rooms = (RoomsUpdate() - ..join = ({}..[id] = (JoinedRoomUpdate() - ..state = resp.state - ..timeline = (TimelineUpdate() - ..limited = false - ..events = resp.chunk - ..prevBatch = resp.end)))), + ..join = membership == Membership.join + ? ({}..[id] = ((JoinedRoomUpdate() + ..state = resp.state + ..timeline = (TimelineUpdate() + ..limited = false + ..events = resp.chunk + ..prevBatch = resp.end)))) + : null + ..leave = membership != Membership.join + ? ({}..[id] = ((LeftRoomUpdate() + ..state = resp.state + ..timeline = (TimelineUpdate() + ..limited = false + ..events = resp.chunk + ..prevBatch = resp.end)))) + : null), sortAtTheEnd: true); };