Skip to content

Commit

Permalink
fix search result amount/count being incorrect
Browse files Browse the repository at this point in the history
Signed-off-by: strawberry <[email protected]>
  • Loading branch information
girlbossceo committed Oct 22, 2024
1 parent c3924db commit 8ed3701
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/api/client/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub(crate) async fn search_events_route(
None => 0, // Default to the start
};

let mut results = Vec::new();
let mut results = Vec::with_capacity(searches.len());
let next_batch = skip.saturating_add(limit);

for _ in 0..next_batch {
Expand All @@ -148,8 +148,8 @@ pub(crate) async fn search_events_route(
}
}

let results: Vec<_> = results
.into_iter()
let final_results: Vec<_> = results
.iter()
.skip(skip)
.stream()
.filter_map(|id| services.rooms.timeline.get_pdu_from_id(id).map(Result::ok))
Expand Down Expand Up @@ -188,7 +188,7 @@ pub(crate) async fn search_events_route(
count: Some(results.len().try_into().unwrap_or_else(|_| uint!(0))),
groups: BTreeMap::new(), // TODO
next_batch,
results,
results: final_results,
state: room_states,
highlights: search_criteria
.search_term
Expand Down

0 comments on commit 8ed3701

Please sign in to comment.