Swap KVP store used for collab favorites (#52756)

Mikayla Maki created

We should generally prefer using the normal key value store

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A

Change summary

crates/collab_ui/src/collab_panel.rs | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

Detailed changes

crates/collab_ui/src/collab_panel.rs 🔗

@@ -9,7 +9,7 @@ use channel::{Channel, ChannelEvent, ChannelStore};
 use client::{ChannelId, Client, Contact, User, UserStore};
 use collections::{HashMap, HashSet};
 use contact_finder::ContactFinder;
-use db::kvp::{GlobalKeyValueStore, KeyValueStore};
+use db::kvp::KeyValueStore;
 use editor::{Editor, EditorElement, EditorStyle};
 use fuzzy::{StringMatch, StringMatchCandidate, match_strings};
 use gpui::{
@@ -473,7 +473,7 @@ impl CollabPanel {
                 });
             }
 
-            let favorites: Vec<ChannelId> = GlobalKeyValueStore::global()
+            let favorites: Vec<ChannelId> = KeyValueStore::global(cx)
                 .read_kvp("favorite_channels")
                 .ok()
                 .flatten()
@@ -1947,12 +1947,6 @@ impl CollabPanel {
     }
 
     fn persist_favorites(&mut self, cx: &mut Context<Self>) {
-        // GlobalKeyValueStore uses a sqlez worker thread that the test
-        // scheduler can't control, causing non-determinism failures.
-        if cfg!(any(test, feature = "test-support")) {
-            return;
-        }
-
         let favorite_ids: Vec<u64> = self
             .channel_store
             .read(cx)
@@ -1960,10 +1954,11 @@ impl CollabPanel {
             .iter()
             .map(|id| id.0)
             .collect();
+        let kvp_store = KeyValueStore::global(cx);
         self.pending_serialization = cx.background_spawn(
             async move {
                 let json = serde_json::to_string(&favorite_ids)?;
-                GlobalKeyValueStore::global()
+                kvp_store
                     .write_kvp("favorite_channels".to_string(), json)
                     .await?;
                 anyhow::Ok(())