Skip to content

Commit

Permalink
fixup! Support filter for request history
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev committed Dec 9, 2024
1 parent f36ff6d commit fb37d56
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/src/room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> requestHistory(
{int historyCount = defaultHistoryCount,
void Function()? onHistoryReceived,
direction = Direction.b}) async {
Future<int> requestHistory({
int historyCount = defaultHistoryCount,
void Function()? onHistoryReceived,
direction = Direction.b,
StateFilter? filter,
}) async {
final prev_batch = this.prev_batch;

final storeInDatabase = !isArchived;
Expand All @@ -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();
Expand Down
1 change: 1 addition & 0 deletions lib/src/timeline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class Timeline {
await room.requestHistory(
historyCount: historyCount,
direction: direction,
filter: filter,
onHistoryReceived: () {
_collectHistoryUpdates = true;
},
Expand Down

0 comments on commit fb37d56

Please sign in to comment.