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

Max Brunsfeld and Nathan Sobo created

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>

Change summary

crates/client/src/user.rs | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

Detailed changes

crates/client/src/user.rs 🔗

@@ -376,9 +376,17 @@ impl UserStore {
         &mut self,
         mut user_ids: Vec<u64>,
         cx: &mut ModelContext<Self>,
-    ) -> Task<Result<Vec<Arc<User>>>> {
+    ) -> Task<Result<()>> {
         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(