From 45b6a9df367195650124d05f78ec626f22ac9141 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 9 May 2022 18:03:24 -0700 Subject: [PATCH] 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 --- crates/client/src/user.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/client/src/user.rs b/crates/client/src/user.rs index a8de7a082d..13439c6893 100644 --- a/crates/client/src/user.rs +++ b/crates/client/src/user.rs @@ -376,9 +376,17 @@ impl UserStore { &mut self, mut user_ids: Vec, cx: &mut ModelContext, - ) -> Task>>> { + ) -> Task> { 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(