From ca09dc1675d1fc281d4006c463e3d9fae7d83ad1 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Mon, 2 Sep 2024 18:16:22 -0700 Subject: [PATCH] filters: add limits to follow filters Signed-off-by: William Casarin --- src/filter.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/filter.rs b/src/filter.rs index 1337c79..85a08ee 100644 --- a/src/filter.rs +++ b/src/filter.rs @@ -85,11 +85,11 @@ pub fn since_optimize_filter(filter: Filter, notes: &[NoteRef]) -> Filter { } pub fn default_limit() -> u64 { - 250 + 500 } pub fn default_remote_limit() -> u64 { - 150 + 250 } pub struct FilteredTags { @@ -99,22 +99,22 @@ pub struct FilteredTags { impl FilteredTags { pub fn into_follow_filter(self) -> Vec { - self.into_filter([1]) + self.into_filter([1], default_limit()) } // TODO: make this more general - pub fn into_filter(self, kinds: I) -> Vec + pub fn into_filter(self, kinds: I, limit: u64) -> Vec where I: IntoIterator + Copy, { let mut filters: Vec = Vec::with_capacity(2); if let Some(authors) = self.authors { - filters.push(authors.kinds(kinds).build()) + filters.push(authors.kinds(kinds).limit(limit).build()) } if let Some(hashtags) = self.hashtags { - filters.push(hashtags.kinds(kinds).build()) + filters.push(hashtags.kinds(kinds).limit(limit).build()) } filters