Avoid sending a GetUsers request for an emptly list of user ids

We don't actually need to return the users at this time. We just call this for its side effect.

Co-authored-by: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld 2022-05-09 18:03:24 -07:00
parent b8aba0972d
commit 45b6a9df36

View file

@ -376,9 +376,17 @@ impl UserStore {
&mut self, &mut self,
mut user_ids: Vec<u64>, mut user_ids: Vec<u64>,
cx: &mut ModelContext<Self>, cx: &mut ModelContext<Self>,
) -> Task<Result<Vec<Arc<User>>>> { ) -> Task<Result<()>> {
user_ids.retain(|id| !self.users.contains_key(id)); user_ids.retain(|id| !self.users.contains_key(id));
self.load_users(proto::GetUsers { user_ids }, cx) if user_ids.is_empty() {
Task::ready(Ok(()))
} else {
let load = self.load_users(proto::GetUsers { user_ids }, cx);
cx.foreground().spawn(async move {
load.await?;
Ok(())
})
}
} }
pub fn fuzzy_search_users( pub fn fuzzy_search_users(