Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix merge conflicts
Mikayla54006054833b
diff --git a/crates/channel/src/channel.rs b/crates/channel/src/channel.rsindex 37f1c0ce44b..d3e2f895643 100644--- a/crates/channel/src/channel.rs+++ b/crates/channel/src/channel.rs@@ -4,7 +4,9 @@ mod channel_store;pub use channel_buffer::{ChannelBuffer, ChannelBufferEvent};pub use channel_chat::{ChannelChat, ChannelChatEvent, ChannelMessage, ChannelMessageId};-pub use channel_store::{Channel, ChannelEvent, ChannelId, ChannelMembership, ChannelStore};+pub use channel_store::{+ Channel, ChannelEvent, ChannelId, ChannelMembership, ChannelPath, ChannelStore,+};use client::Client;use std::sync::Arc;diff --git a/crates/channel/src/channel_store.rs b/crates/channel/src/channel_store.rsindex eec727c6dcc..208247aca55 100644--- a/crates/channel/src/channel_store.rs+++ b/crates/channel/src/channel_store.rs@@ -7,11 +7,11 @@ use collections::{hash_map, HashMap, HashSet};use futures::{channel::mpsc, future::Shared, Future, FutureExt, StreamExt};use gpui::{AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, Task, WeakModelHandle};use rpc::{proto, TypedEnvelope};-use std::{mem, sync::Arc, time::Duration};+use serde_derive::{Deserialize, Serialize};+use std::{mem, ops::Deref, sync::Arc, time::Duration};use util::ResultExt;use self::channel_index::ChannelIndex;-pub use self::channel_index::ChannelPath;pub const RECONNECT_TIMEOUT: Duration = Duration::from_secs(30);@@ -40,6 +40,29 @@ pub struct Channel {pub name: String,}+#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Serialize, Deserialize)]+pub struct ChannelPath(Arc<[ChannelId]>);++impl Deref for ChannelPath {+ type Target = [ChannelId];++ fn deref(&self) -> &Self::Target {+ &self.0+ }+}++impl ChannelPath {+ pub fn parent_id(&self) -> Option<ChannelId> {+ self.0.len().checked_sub(2).map(|i| self.0[i])+ }+}++impl Default for ChannelPath {+ fn default() -> Self {+ ChannelPath(Arc::from([]))+ }+}+pub struct ChannelMembership {pub user: Arc<User>,pub kind: proto::channel_member::Kind,diff --git a/crates/channel/src/channel_store/channel_index.rs b/crates/channel/src/channel_store/channel_index.rsindex 31115854670..dd911ab363e 100644--- a/crates/channel/src/channel_store/channel_index.rs+++ b/crates/channel/src/channel_store/channel_index.rs@@ -2,34 +2,12 @@ use std::{ops::Deref, sync::Arc};use collections::HashMap;use rpc::proto;-use serde_derive::{Deserialize, Serialize};use crate::{Channel, ChannelId};-pub type ChannelsById = HashMap<ChannelId, Arc<Channel>>;--#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Serialize, Deserialize)]-pub struct ChannelPath(Arc<[ChannelId]>);--impl Deref for ChannelPath {- type Target = [ChannelId];-- fn deref(&self) -> &Self::Target {- &self.0- }-}+use super::ChannelPath;-impl ChannelPath {- pub fn parent_id(&self) -> Option<ChannelId> {- self.0.len().checked_sub(2).map(|i| self.0[i])- }-}--impl Default for ChannelPath {- fn default() -> Self {- ChannelPath(Arc::from([]))- }-}+pub type ChannelsById = HashMap<ChannelId, Arc<Channel>>;#[derive(Default, Debug)]pub struct ChannelIndex {diff --git a/crates/collab/src/db/tests/db_tests.rs b/crates/collab/src/db/tests/db_tests.rsindex 0e6a0529c4f..d5e3349d475 100644--- a/crates/collab/src/db/tests/db_tests.rs+++ b/crates/collab/src/db/tests/db_tests.rs@@ -750,11 +750,11 @@ async fn test_channels(db: &Arc<Database>) {);// Remove a single channel- db.remove_channel(crdb_id, a_id).await.unwrap();+ db.delete_channel(crdb_id, a_id).await.unwrap();assert!(db.get_channel(crdb_id, a_id).await.unwrap().is_none());// Remove a channel tree- let (mut channel_ids, user_ids) = db.remove_channel(rust_id, a_id).await.unwrap();+ let (mut channel_ids, user_ids) = db.delete_channel(rust_id, a_id).await.unwrap();channel_ids.sort();assert_eq!(channel_ids, &[rust_id, cargo_id, cargo_ra_id]);assert_eq!(user_ids, &[a_id]);diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rsindex 1d89c6fe42a..04478133564 100644--- a/crates/collab/src/rpc.rs+++ b/crates/collab/src/rpc.rs@@ -3,8 +3,8 @@ mod connection_pool;use crate::{auth,db::{- self, Channel, ChannelId, ChannelsForUser, Database, MessageId, ProjectId, RoomId, ServerId, User,- UserId,+ self, Channel, ChannelId, ChannelsForUser, Database, MessageId, ProjectId, RoomId,+ ServerId, User, UserId,},executor::Executor,AppState, Result,diff --git a/crates/collab/src/tests/channel_message_tests.rs b/crates/collab/src/tests/channel_message_tests.rsindex 1a9460c6cfb..58494c538b4 100644--- a/crates/collab/src/tests/channel_message_tests.rs+++ b/crates/collab/src/tests/channel_message_tests.rs@@ -15,7 +15,12 @@ async fn test_basic_channel_messages(let client_b = server.create_client(cx_b, "user_b").await;let channel_id = server- .make_channel("the-channel", (&client_a, cx_a), &mut [(&client_b, cx_b)])+ .make_channel(+ "the-channel",+ None,+ (&client_a, cx_a),+ &mut [(&client_b, cx_b)],+ ).await;let channel_chat_a = client_a@@ -68,7 +73,12 @@ async fn test_rejoin_channel_chat(let client_b = server.create_client(cx_b, "user_b").await;let channel_id = server- .make_channel("the-channel", (&client_a, cx_a), &mut [(&client_b, cx_b)])+ .make_channel(+ "the-channel",+ None,+ (&client_a, cx_a),+ &mut [(&client_b, cx_b)],+ ).await;let channel_chat_a = client_a@@ -139,6 +149,7 @@ async fn test_remove_channel_message(let channel_id = server.make_channel("the-channel",+ None,(&client_a, cx_a),&mut [(&client_b, cx_b), (&client_c, cx_c)],)diff --git a/crates/collab_ui/src/chat_panel.rs b/crates/collab_ui/src/chat_panel.rsindex 087f2e1b8e5..4200ada36bf 100644--- a/crates/collab_ui/src/chat_panel.rs+++ b/crates/collab_ui/src/chat_panel.rs@@ -167,7 +167,7 @@ impl ChatPanel {.channel_store.read(cx).channel_at_index(selected_ix)- .map(|e| e.1.id);+ .map(|e| e.0.id);if let Some(selected_channel_id) = selected_channel_id {this.select_channel(selected_channel_id, cx).detach_and_log_err(cx);@@ -391,7 +391,7 @@ impl ChatPanel {(ItemType::Unselected, true) => &theme.channel_select.hovered_item,};- let channel = &channel_store.read(cx).channel_at_index(ix).unwrap().1;+ let channel = &channel_store.read(cx).channel_at_index(ix).unwrap().0;let channel_id = channel.id;let mut row = Flex::row()diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rsindex d9c28b9049a..2ed2a1a230c 100644--- a/crates/collab_ui/src/collab_panel.rs+++ b/crates/collab_ui/src/collab_panel.rs@@ -5,13 +5,12 @@ use crate::{channel_view::{self, ChannelView},chat_panel::ChatPanel,face_pile::FacePile,- CollaborationPanelSettings,+ panel_settings, CollaborationPanelSettings,};use anyhow::Result;use call::ActiveCall;-use channel::{Channel, ChannelEvent, ChannelId, ChannelStore, ChannelPath};-use channel_modal::ChannelModal;use channel::{Channel, ChannelEvent, ChannelId, ChannelPath, ChannelStore};+use channel_modal::ChannelModal;use client::{proto::PeerId, Client, Contact, User, UserStore};use contact_finder::ContactFinder;use context_menu::{ContextMenu, ContextMenuItem};@@ -195,7 +194,6 @@ pub fn init(cx: &mut AppContext) {cx.add_action(CollabPanel::collapse_selected_channel);cx.add_action(CollabPanel::expand_selected_channel);cx.add_action(CollabPanel::open_channel_notes);- cx.add_action(CollabPanel::open_channel_buffer);cx.add_action(|panel: &mut CollabPanel, action: &StartMoveChannel, _: &mut ViewContext<CollabPanel>| {