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 Oct 17, 2024
1 parent 3d0168e commit 420ed04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/src/room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ class Room {
threadRootEventId: threadRootEventId,
threadLastEventId: threadLastEventId);
}

final eventContent = getEventContentFromMsgText(
message: message,
parseMarkdown: parseMarkdown,
Expand Down Expand Up @@ -1030,10 +1030,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 @@ -1046,7 +1048,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 420ed04

Please sign in to comment.