Fix merge conflicts

This commit is contained in:
Mikayla 2023-09-15 12:30:26 -07:00
parent f9fff3a7b2
commit 5400605483
No known key found for this signature in database
8 changed files with 51 additions and 39 deletions

View file

@ -4,7 +4,9 @@ mod channel_store;
pub use channel_buffer::{ChannelBuffer, ChannelBufferEvent}; pub use channel_buffer::{ChannelBuffer, ChannelBufferEvent};
pub use channel_chat::{ChannelChat, ChannelChatEvent, ChannelMessage, ChannelMessageId}; 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 client::Client;
use std::sync::Arc; use std::sync::Arc;

View file

@ -7,11 +7,11 @@ use collections::{hash_map, HashMap, HashSet};
use futures::{channel::mpsc, future::Shared, Future, FutureExt, StreamExt}; use futures::{channel::mpsc, future::Shared, Future, FutureExt, StreamExt};
use gpui::{AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, Task, WeakModelHandle}; use gpui::{AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, Task, WeakModelHandle};
use rpc::{proto, TypedEnvelope}; 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 util::ResultExt;
use self::channel_index::ChannelIndex; use self::channel_index::ChannelIndex;
pub use self::channel_index::ChannelPath;
pub const RECONNECT_TIMEOUT: Duration = Duration::from_secs(30); pub const RECONNECT_TIMEOUT: Duration = Duration::from_secs(30);
@ -40,6 +40,29 @@ pub struct Channel {
pub name: String, 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 struct ChannelMembership {
pub user: Arc<User>, pub user: Arc<User>,
pub kind: proto::channel_member::Kind, pub kind: proto::channel_member::Kind,

View file

@ -2,35 +2,13 @@ use std::{ops::Deref, sync::Arc};
use collections::HashMap; use collections::HashMap;
use rpc::proto; use rpc::proto;
use serde_derive::{Deserialize, Serialize};
use crate::{Channel, ChannelId}; use crate::{Channel, ChannelId};
use super::ChannelPath;
pub type ChannelsById = HashMap<ChannelId, Arc<Channel>>; 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
}
}
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([]))
}
}
#[derive(Default, Debug)] #[derive(Default, Debug)]
pub struct ChannelIndex { pub struct ChannelIndex {
paths: Vec<ChannelPath>, paths: Vec<ChannelPath>,

View file

@ -750,11 +750,11 @@ async fn test_channels(db: &Arc<Database>) {
); );
// Remove a single channel // 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()); assert!(db.get_channel(crdb_id, a_id).await.unwrap().is_none());
// Remove a channel tree // 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(); channel_ids.sort();
assert_eq!(channel_ids, &[rust_id, cargo_id, cargo_ra_id]); assert_eq!(channel_ids, &[rust_id, cargo_id, cargo_ra_id]);
assert_eq!(user_ids, &[a_id]); assert_eq!(user_ids, &[a_id]);

View file

@ -3,8 +3,8 @@ mod connection_pool;
use crate::{ use crate::{
auth, auth,
db::{ db::{
self, Channel, ChannelId, ChannelsForUser, Database, MessageId, ProjectId, RoomId, ServerId, User, self, Channel, ChannelId, ChannelsForUser, Database, MessageId, ProjectId, RoomId,
UserId, ServerId, User, UserId,
}, },
executor::Executor, executor::Executor,
AppState, Result, AppState, Result,

View file

@ -15,7 +15,12 @@ async fn test_basic_channel_messages(
let client_b = server.create_client(cx_b, "user_b").await; let client_b = server.create_client(cx_b, "user_b").await;
let channel_id = server 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; .await;
let channel_chat_a = client_a 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 client_b = server.create_client(cx_b, "user_b").await;
let channel_id = server 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; .await;
let channel_chat_a = client_a let channel_chat_a = client_a
@ -139,6 +149,7 @@ async fn test_remove_channel_message(
let channel_id = server let channel_id = server
.make_channel( .make_channel(
"the-channel", "the-channel",
None,
(&client_a, cx_a), (&client_a, cx_a),
&mut [(&client_b, cx_b), (&client_c, cx_c)], &mut [(&client_b, cx_b), (&client_c, cx_c)],
) )

View file

@ -167,7 +167,7 @@ impl ChatPanel {
.channel_store .channel_store
.read(cx) .read(cx)
.channel_at_index(selected_ix) .channel_at_index(selected_ix)
.map(|e| e.1.id); .map(|e| e.0.id);
if let Some(selected_channel_id) = selected_channel_id { if let Some(selected_channel_id) = selected_channel_id {
this.select_channel(selected_channel_id, cx) this.select_channel(selected_channel_id, cx)
.detach_and_log_err(cx); .detach_and_log_err(cx);
@ -391,7 +391,7 @@ impl ChatPanel {
(ItemType::Unselected, true) => &theme.channel_select.hovered_item, (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 channel_id = channel.id;
let mut row = Flex::row() let mut row = Flex::row()

View file

@ -5,13 +5,12 @@ use crate::{
channel_view::{self, ChannelView}, channel_view::{self, ChannelView},
chat_panel::ChatPanel, chat_panel::ChatPanel,
face_pile::FacePile, face_pile::FacePile,
CollaborationPanelSettings, panel_settings, CollaborationPanelSettings,
}; };
use anyhow::Result; use anyhow::Result;
use call::ActiveCall; use call::ActiveCall;
use channel::{Channel, ChannelEvent, ChannelId, ChannelStore, ChannelPath};
use channel_modal::ChannelModal;
use channel::{Channel, ChannelEvent, ChannelId, ChannelPath, ChannelStore}; use channel::{Channel, ChannelEvent, ChannelId, ChannelPath, ChannelStore};
use channel_modal::ChannelModal;
use client::{proto::PeerId, Client, Contact, User, UserStore}; use client::{proto::PeerId, Client, Contact, User, UserStore};
use contact_finder::ContactFinder; use contact_finder::ContactFinder;
use context_menu::{ContextMenu, ContextMenuItem}; 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::collapse_selected_channel);
cx.add_action(CollabPanel::expand_selected_channel); cx.add_action(CollabPanel::expand_selected_channel);
cx.add_action(CollabPanel::open_channel_notes); cx.add_action(CollabPanel::open_channel_notes);
cx.add_action(CollabPanel::open_channel_buffer);
cx.add_action( cx.add_action(
|panel: &mut CollabPanel, action: &StartMoveChannel, _: &mut ViewContext<CollabPanel>| { |panel: &mut CollabPanel, action: &StartMoveChannel, _: &mut ViewContext<CollabPanel>| {