From 3fdd19f7a26a664629a6fddd3ebcbe6fc9720f22 Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 9 Dec 2024 15:17:11 +0800 Subject: [PATCH] chore: do not pull object when object ids is empty --- .../rust-lib/flowy-database2/src/manager.rs | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/frontend/rust-lib/flowy-database2/src/manager.rs b/frontend/rust-lib/flowy-database2/src/manager.rs index 8246da8a97895..cf14295e4c276 100644 --- a/frontend/rust-lib/flowy-database2/src/manager.rs +++ b/frontend/rust-lib/flowy-database2/src/manager.rs @@ -903,18 +903,21 @@ impl DatabaseCollabService for WorkspaceDatabaseCollabServiceImpl { encoded_collab_by_id.insert(k, v); } - // 2. Fetch remaining collabs from remote - let remote_collabs = self - .batch_get_encode_collab(object_ids, collab_type) - .await?; + if !object_ids.is_empty() { + // 2. Fetch remaining collabs from remote + let remote_collabs = self + .batch_get_encode_collab(object_ids, collab_type) + .await?; - trace!( - "[Database]: load {} database row from remote", - remote_collabs.len() - ); - for (k, v) in remote_collabs { - encoded_collab_by_id.insert(k, v); + trace!( + "[Database]: load {} database row from remote", + remote_collabs.len() + ); + for (k, v) in remote_collabs { + encoded_collab_by_id.insert(k, v); + } } + Ok(encoded_collab_by_id) }