From fb37d5679954332fb9bcdbf4895971689ffb8952 Mon Sep 17 00:00:00 2001 From: HuyNguyen Date: Thu, 17 Oct 2024 11:11:16 +0700 Subject: [PATCH] fixup! Support filter for request history --- lib/src/room.dart | 12 +++++++----- lib/src/timeline.dart | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/src/room.dart b/lib/src/room.dart index 6dd8afb2..9aefeb70 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -1037,10 +1037,12 @@ class Room { /// be received maximum. When the request is answered, [onHistoryReceived] will be triggered **before** /// the historical events will be published in the onEvent stream. /// Returns the actual count of received timeline events. - Future requestHistory( - {int historyCount = defaultHistoryCount, - void Function()? onHistoryReceived, - direction = Direction.b}) async { + Future requestHistory({ + int historyCount = defaultHistoryCount, + void Function()? onHistoryReceived, + direction = Direction.b, + StateFilter? filter, + }) async { final prev_batch = this.prev_batch; final storeInDatabase = !isArchived; @@ -1053,7 +1055,7 @@ class Room { direction, from: prev_batch, limit: historyCount, - filter: jsonEncode(StateFilter(lazyLoadMembers: true).toJson()), + filter: jsonEncode((filter ?? StateFilter(lazyLoadMembers: true)).toJson()), ); if (onHistoryReceived != null) onHistoryReceived(); diff --git a/lib/src/timeline.dart b/lib/src/timeline.dart index ce9938bc..66481fef 100644 --- a/lib/src/timeline.dart +++ b/lib/src/timeline.dart @@ -166,6 +166,7 @@ class Timeline { await room.requestHistory( historyCount: historyCount, direction: direction, + filter: filter, onHistoryReceived: () { _collectHistoryUpdates = true; },