From 2b8822fd082c7178831a10fe96403ea99b26a235 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 3 Jan 2024 10:30:52 -0800 Subject: [PATCH] Remove 2 suffix for welcome, vcs_menu, quick_action_bar, collab_ui Co-authored-by: Mikayla --- Cargo.lock | 100 +- Cargo.toml | 5 +- crates/collab2/Cargo.toml | 4 +- crates/collab_ui/Cargo.toml | 69 +- crates/collab_ui/src/channel_view.rs | 210 +- crates/collab_ui/src/chat_panel.rs | 737 ++-- .../src/chat_panel/message_editor.rs | 109 +- crates/collab_ui/src/collab_panel.rs | 3355 ++++++----------- .../src/collab_panel/channel_modal.rs | 638 ++-- .../src/collab_panel/contact_finder.rs | 228 +- crates/collab_ui/src/collab_titlebar_item.rs | 1618 +++----- crates/collab_ui/src/collab_ui.rs | 124 +- crates/collab_ui/src/face_pile.rs | 123 +- crates/collab_ui/src/notification_panel.rs | 655 ++-- .../incoming_call_notification.rs | 252 +- .../project_shared_notification.rs | 205 +- crates/collab_ui/src/panel_settings.rs | 21 +- crates/collab_ui2/Cargo.toml | 81 - crates/collab_ui2/src/channel_view.rs | 448 --- crates/collab_ui2/src/chat_panel.rs | 704 ---- .../src/chat_panel/message_editor.rs | 296 -- crates/collab_ui2/src/collab_panel.rs | 2539 ------------- .../src/collab_panel/channel_modal.rs | 575 --- .../src/collab_panel/contact_finder.rs | 163 - crates/collab_ui2/src/collab_titlebar_item.rs | 586 --- crates/collab_ui2/src/collab_ui.rs | 167 - crates/collab_ui2/src/face_pile.rs | 30 - crates/collab_ui2/src/notification_panel.rs | 755 ---- crates/collab_ui2/src/notifications.rs | 11 - .../incoming_call_notification.rs | 163 - .../project_shared_notification.rs | 180 - crates/collab_ui2/src/panel_settings.rs | 70 - crates/quick_action_bar/Cargo.toml | 19 +- .../quick_action_bar/src/quick_action_bar.rs | 238 +- crates/quick_action_bar2/Cargo.toml | 22 - .../quick_action_bar2/src/quick_action_bar.rs | 191 - crates/vcs_menu/Cargo.toml | 12 +- crates/vcs_menu/src/lib.rs | 297 +- crates/vcs_menu2/Cargo.toml | 17 - crates/vcs_menu2/src/lib.rs | 358 -- crates/welcome/Cargo.toml | 31 +- crates/welcome/src/base_keymap_picker.rs | 124 +- crates/welcome/src/base_keymap_setting.rs | 6 +- crates/welcome/src/welcome.rs | 430 ++- crates/welcome2/Cargo.toml | 37 - crates/welcome2/src/base_keymap_picker.rs | 208 - crates/welcome2/src/base_keymap_setting.rs | 65 - crates/welcome2/src/welcome.rs | 283 -- crates/zed/Cargo.toml | 6 +- 49 files changed, 3529 insertions(+), 14036 deletions(-) delete mode 100644 crates/collab_ui2/Cargo.toml delete mode 100644 crates/collab_ui2/src/channel_view.rs delete mode 100644 crates/collab_ui2/src/chat_panel.rs delete mode 100644 crates/collab_ui2/src/chat_panel/message_editor.rs delete mode 100644 crates/collab_ui2/src/collab_panel.rs delete mode 100644 crates/collab_ui2/src/collab_panel/channel_modal.rs delete mode 100644 crates/collab_ui2/src/collab_panel/contact_finder.rs delete mode 100644 crates/collab_ui2/src/collab_titlebar_item.rs delete mode 100644 crates/collab_ui2/src/collab_ui.rs delete mode 100644 crates/collab_ui2/src/face_pile.rs delete mode 100644 crates/collab_ui2/src/notification_panel.rs delete mode 100644 crates/collab_ui2/src/notifications.rs delete mode 100644 crates/collab_ui2/src/notifications/incoming_call_notification.rs delete mode 100644 crates/collab_ui2/src/notifications/project_shared_notification.rs delete mode 100644 crates/collab_ui2/src/panel_settings.rs delete mode 100644 crates/quick_action_bar2/Cargo.toml delete mode 100644 crates/quick_action_bar2/src/quick_action_bar.rs delete mode 100644 crates/vcs_menu2/Cargo.toml delete mode 100644 crates/vcs_menu2/src/lib.rs delete mode 100644 crates/welcome2/Cargo.toml delete mode 100644 crates/welcome2/src/base_keymap_picker.rs delete mode 100644 crates/welcome2/src/base_keymap_setting.rs delete mode 100644 crates/welcome2/src/welcome.rs diff --git a/Cargo.lock b/Cargo.lock index 801711ef33..9e4815f153 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1762,7 +1762,7 @@ dependencies = [ "anyhow", "async-trait", "async-tungstenite", - "audio2", + "audio", "axum", "axum-extra", "base64 0.13.1", @@ -1771,7 +1771,7 @@ dependencies = [ "clap 3.2.25", "client2", "clock", - "collab_ui2", + "collab_ui", "collections", "ctor", "dashmap", @@ -1831,53 +1831,6 @@ dependencies = [ [[package]] name = "collab_ui" version = "0.1.0" -dependencies = [ - "anyhow", - "auto_update", - "call", - "channel", - "client", - "clock", - "collections", - "context_menu", - "db", - "drag_and_drop", - "editor", - "feature_flags", - "feedback", - "futures 0.3.28", - "fuzzy", - "gpui", - "language", - "lazy_static", - "log", - "menu", - "notifications", - "picker", - "postage", - "pretty_assertions", - "project", - "recent_projects", - "rich_text", - "rpc", - "schemars", - "serde", - "serde_derive", - "settings", - "smallvec", - "theme", - "theme_selector", - "time", - "tree-sitter-markdown", - "util", - "vcs_menu", - "workspace", - "zed-actions", -] - -[[package]] -name = "collab_ui2" -version = "0.1.0" dependencies = [ "anyhow", "auto_update2", @@ -1916,7 +1869,7 @@ dependencies = [ "tree-sitter-markdown", "ui2", "util", - "vcs_menu2", + "vcs_menu", "workspace2", "zed_actions2", ] @@ -7010,7 +6963,7 @@ dependencies = [ ] [[package]] -name = "quick_action_bar2" +name = "quick_action_bar" version = "0.1.0" dependencies = [ "assistant2", @@ -10604,20 +10557,6 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vcs_menu" version = "0.1.0" -dependencies = [ - "anyhow", - "fs", - "fuzzy", - "gpui", - "picker", - "theme", - "util", - "workspace", -] - -[[package]] -name = "vcs_menu2" -version = "0.1.0" dependencies = [ "anyhow", "fs2", @@ -11093,31 +11032,6 @@ checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" [[package]] name = "welcome" version = "0.1.0" -dependencies = [ - "anyhow", - "client", - "db", - "editor", - "fs", - "fuzzy", - "gpui", - "install_cli", - "log", - "picker", - "project", - "schemars", - "serde", - "settings", - "theme", - "theme_selector", - "util", - "vim", - "workspace", -] - -[[package]] -name = "welcome2" -version = "0.1.0" dependencies = [ "anyhow", "client2", @@ -11557,7 +11471,7 @@ dependencies = [ "chrono", "cli", "client2", - "collab_ui2", + "collab_ui", "collections", "command_palette2", "copilot2", @@ -11598,7 +11512,7 @@ dependencies = [ "project2", "project_panel2", "project_symbols2", - "quick_action_bar2", + "quick_action_bar", "rand 0.8.5", "recent_projects2", "regex", @@ -11661,7 +11575,7 @@ dependencies = [ "util", "uuid 1.4.1", "vim2", - "welcome2", + "welcome", "workspace2", "zed_actions2", ] diff --git a/Cargo.toml b/Cargo.toml index b26b084ede..06e3f63522 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,6 @@ members = [ "crates/collab", "crates/collab2", "crates/collab_ui", - "crates/collab_ui2", "crates/collections", "crates/command_palette", "crates/command_palette2", @@ -91,7 +90,7 @@ members = [ "crates/project_panel2", "crates/project_symbols", "crates/project_symbols2", - "crates/quick_action_bar2", + "crates/quick_action_bar", "crates/recent_projects", "crates/recent_projects2", "crates/rope", @@ -123,10 +122,8 @@ members = [ "crates/story", "crates/vim", "crates/vcs_menu", - "crates/vcs_menu2", "crates/workspace2", "crates/welcome", - "crates/welcome2", "crates/xtask", "crates/zed", "crates/zed-actions", diff --git a/crates/collab2/Cargo.toml b/crates/collab2/Cargo.toml index 06443afdbc..7059733809 100644 --- a/crates/collab2/Cargo.toml +++ b/crates/collab2/Cargo.toml @@ -60,7 +60,7 @@ tracing-subscriber = { version = "0.3.11", features = ["env-filter", "json"] } uuid.workspace = true [dev-dependencies] -audio = { package = "audio2", path = "../audio2" } +audio = { path = "../audio" } collections = { path = "../collections", features = ["test-support"] } gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] } call = { package = "call2", path = "../call2", features = ["test-support"] } @@ -81,7 +81,7 @@ settings = { package = "settings2", path = "../settings2", features = ["test-sup theme = { package = "theme2", path = "../theme2" } workspace = { package = "workspace2", path = "../workspace2", features = ["test-support"] } -collab_ui = { path = "../collab_ui2", package = "collab_ui2", features = ["test-support"] } +collab_ui = { path = "../collab_ui", features = ["test-support"] } async-trait.workspace = true pretty_assertions.workspace = true diff --git a/crates/collab_ui/Cargo.toml b/crates/collab_ui/Cargo.toml index 791c6b2fa7..fcce4fbfca 100644 --- a/crates/collab_ui/Cargo.toml +++ b/crates/collab_ui/Cargo.toml @@ -22,35 +22,36 @@ test-support = [ ] [dependencies] -auto_update = { path = "../auto_update" } -db = { path = "../db" } -call = { path = "../call" } -client = { path = "../client" } -channel = { path = "../channel" } +auto_update = { package = "auto_update2", path = "../auto_update2" } +db = { package = "db2", path = "../db2" } +call = { package = "call2", path = "../call2" } +client = { package = "client2", path = "../client2" } +channel = { package = "channel2", path = "../channel2" } clock = { path = "../clock" } collections = { path = "../collections" } -context_menu = { path = "../context_menu" } -drag_and_drop = { path = "../drag_and_drop" } -editor = { path = "../editor" } -feedback = { path = "../feedback" } -fuzzy = { path = "../fuzzy" } -gpui = { path = "../gpui" } -language = { path = "../language" } -menu = { path = "../menu" } -notifications = { path = "../notifications" } -rich_text = { path = "../rich_text" } -picker = { path = "../picker" } -project = { path = "../project" } -recent_projects = { path = "../recent_projects" } -rpc = { path = "../rpc" } -settings = { path = "../settings" } -feature_flags = {path = "../feature_flags"} -theme = { path = "../theme" } -theme_selector = { path = "../theme_selector" } +# context_menu = { path = "../context_menu" } +# drag_and_drop = { path = "../drag_and_drop" } +editor = { package="editor2", path = "../editor2" } +feedback = { package = "feedback2", path = "../feedback2" } +fuzzy = { package = "fuzzy2", path = "../fuzzy2" } +gpui = { package = "gpui2", path = "../gpui2" } +language = { package = "language2", path = "../language2" } +menu = { package = "menu2", path = "../menu2" } +notifications = { package = "notifications2", path = "../notifications2" } +rich_text = { package = "rich_text2", path = "../rich_text2" } +picker = { package = "picker2", path = "../picker2" } +project = { package = "project2", path = "../project2" } +recent_projects = { package = "recent_projects2", path = "../recent_projects2" } +rpc = { package ="rpc2", path = "../rpc2" } +settings = { package = "settings2", path = "../settings2" } +feature_flags = { package = "feature_flags2", path = "../feature_flags2"} +theme = { package = "theme2", path = "../theme2" } +theme_selector = { package = "theme_selector2", path = "../theme_selector2" } vcs_menu = { path = "../vcs_menu" } +ui = { package = "ui2", path = "../ui2" } util = { path = "../util" } -workspace = { path = "../workspace" } -zed-actions = {path = "../zed-actions"} +workspace = { package = "workspace2", path = "../workspace2" } +zed-actions = { package="zed_actions2", path = "../zed_actions2"} anyhow.workspace = true futures.workspace = true @@ -64,17 +65,17 @@ time.workspace = true smallvec.workspace = true [dev-dependencies] -call = { path = "../call", features = ["test-support"] } -client = { path = "../client", features = ["test-support"] } +call = { package = "call2", path = "../call2", features = ["test-support"] } +client = { package = "client2", path = "../client2", features = ["test-support"] } collections = { path = "../collections", features = ["test-support"] } -editor = { path = "../editor", features = ["test-support"] } -gpui = { path = "../gpui", features = ["test-support"] } -notifications = { path = "../notifications", features = ["test-support"] } -project = { path = "../project", features = ["test-support"] } -rpc = { path = "../rpc", features = ["test-support"] } -settings = { path = "../settings", features = ["test-support"] } +editor = { package = "editor2", path = "../editor2", features = ["test-support"] } +gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] } +notifications = { package = "notifications2", path = "../notifications2", features = ["test-support"] } +project = { package = "project2", path = "../project2", features = ["test-support"] } +rpc = { package = "rpc2", path = "../rpc2", features = ["test-support"] } +settings = { package = "settings2", path = "../settings2", features = ["test-support"] } util = { path = "../util", features = ["test-support"] } -workspace = { path = "../workspace", features = ["test-support"] } +workspace = { package = "workspace2", path = "../workspace2", features = ["test-support"] } pretty_assertions.workspace = true tree-sitter-markdown.workspace = true diff --git a/crates/collab_ui/src/channel_view.rs b/crates/collab_ui/src/channel_view.rs index fe46f3bb3e..df2adbaabe 100644 --- a/crates/collab_ui/src/channel_view.rs +++ b/crates/collab_ui/src/channel_view.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Result}; +use anyhow::Result; use call::report_call_event_for_channel; use channel::{Channel, ChannelBuffer, ChannelBufferEvent, ChannelId, ChannelStore}; use client::{ @@ -6,20 +6,18 @@ use client::{ Collaborator, ParticipantIndex, }; use collections::HashMap; -use editor::{CollaborationHub, Editor}; +use editor::{CollaborationHub, Editor, EditorEvent}; use gpui::{ - actions, - elements::{ChildView, Label}, - geometry::vector::Vector2F, - AnyElement, AnyViewHandle, AppContext, Element, Entity, ModelHandle, Subscription, Task, View, - ViewContext, ViewHandle, + actions, AnyElement, AnyView, AppContext, Entity as _, EventEmitter, FocusableView, + IntoElement as _, Model, Pixels, Point, Render, Subscription, Task, View, ViewContext, + VisualContext as _, WindowContext, }; use project::Project; -use smallvec::SmallVec; use std::{ any::{Any, TypeId}, sync::Arc, }; +use ui::{prelude::*, Label}; use util::ResultExt; use workspace::{ item::{FollowableItem, Item, ItemEvent, ItemHandle}, @@ -28,17 +26,17 @@ use workspace::{ ItemNavHistory, Pane, SaveIntent, ViewId, Workspace, WorkspaceId, }; -actions!(channel_view, [Deploy]); +actions!(collab, [Deploy]); pub fn init(cx: &mut AppContext) { register_followable_item::(cx) } pub struct ChannelView { - pub editor: ViewHandle, - project: ModelHandle, - channel_store: ModelHandle, - channel_buffer: ModelHandle, + pub editor: View, + project: Model, + channel_store: Model, + channel_buffer: Model, remote_id: Option, _editor_event_subscription: Subscription, } @@ -46,9 +44,9 @@ pub struct ChannelView { impl ChannelView { pub fn open( channel_id: ChannelId, - workspace: ViewHandle, - cx: &mut AppContext, - ) -> Task>> { + workspace: View, + cx: &mut WindowContext, + ) -> Task>> { let pane = workspace.read(cx).active_pane().clone(); let channel_view = Self::open_in_pane(channel_id, pane.clone(), workspace.clone(), cx); cx.spawn(|mut cx| async move { @@ -61,17 +59,17 @@ impl ChannelView { cx, ); pane.add_item(Box::new(channel_view.clone()), true, true, None, cx); - }); + })?; anyhow::Ok(channel_view) }) } pub fn open_in_pane( channel_id: ChannelId, - pane: ViewHandle, - workspace: ViewHandle, - cx: &mut AppContext, - ) -> Task>> { + pane: View, + workspace: View, + cx: &mut WindowContext, + ) -> Task>> { let workspace = workspace.read(cx); let project = workspace.project().to_owned(); let channel_store = ChannelStore::global(cx); @@ -91,7 +89,7 @@ impl ChannelView { buffer.set_language(Some(markdown), cx); } }) - }); + })?; pane.update(&mut cx, |pane, cx| { let buffer_id = channel_buffer.read(cx).remote_id(cx); @@ -107,7 +105,7 @@ impl ChannelView { } } - let view = cx.add_view(|cx| { + let view = cx.new_view(|cx| { let mut this = Self::new(project, channel_store, channel_buffer, cx); this.acknowledge_buffer_version(cx); this @@ -117,7 +115,7 @@ impl ChannelView { // replace that. if let Some(existing_item) = existing_view { if let Some(ix) = pane.index_for_item(&existing_item) { - pane.close_item_by_id(existing_item.id(), SaveIntent::Skip, cx) + pane.close_item_by_id(existing_item.entity_id(), SaveIntent::Skip, cx) .detach(); pane.add_item(Box::new(view.clone()), true, true, Some(ix), cx); } @@ -125,18 +123,17 @@ impl ChannelView { view }) - .ok_or_else(|| anyhow!("pane was dropped")) }) } pub fn new( - project: ModelHandle, - channel_store: ModelHandle, - channel_buffer: ModelHandle, + project: Model, + channel_store: Model, + channel_buffer: Model, cx: &mut ViewContext, ) -> Self { let buffer = channel_buffer.read(cx).buffer(); - let editor = cx.add_view(|cx| { + let editor = cx.new_view(|cx| { let mut editor = Editor::for_buffer(buffer, None, cx); editor.set_collaboration_hub(Box::new(ChannelBufferCollaborationHub( channel_buffer.clone(), @@ -149,7 +146,8 @@ impl ChannelView { ); editor }); - let _editor_event_subscription = cx.subscribe(&editor, |_, _, e, cx| cx.emit(e.clone())); + let _editor_event_subscription = + cx.subscribe(&editor, |_, _, e: &EditorEvent, cx| cx.emit(e.clone())); cx.subscribe(&channel_buffer, Self::handle_channel_buffer_event) .detach(); @@ -170,7 +168,7 @@ impl ChannelView { fn handle_channel_buffer_event( &mut self, - _: ModelHandle, + _: Model, event: &ChannelBufferEvent, cx: &mut ViewContext, ) { @@ -182,12 +180,12 @@ impl ChannelView { ChannelBufferEvent::ChannelChanged => { self.editor.update(cx, |editor, cx| { editor.set_read_only(!self.channel(cx).is_some_and(|c| c.can_edit_notes())); - cx.emit(editor::Event::TitleChanged); + cx.emit(editor::EditorEvent::TitleChanged); cx.notify() }); } ChannelBufferEvent::BufferEdited => { - if cx.is_self_focused() || self.editor.is_focused(cx) { + if self.editor.read(cx).is_focused(cx) { self.acknowledge_buffer_version(cx); } else { self.channel_store.update(cx, |store, cx| { @@ -205,7 +203,7 @@ impl ChannelView { } } - fn acknowledge_buffer_version(&mut self, cx: &mut ViewContext<'_, '_, ChannelView>) { + fn acknowledge_buffer_version(&mut self, cx: &mut ViewContext) { self.channel_store.update(cx, |store, cx| { let channel_buffer = self.channel_buffer.read(cx); store.acknowledge_notes_version( @@ -221,49 +219,39 @@ impl ChannelView { } } -impl Entity for ChannelView { - type Event = editor::Event; +impl EventEmitter for ChannelView {} + +impl Render for ChannelView { + fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { + self.editor.clone() + } } -impl View for ChannelView { - fn ui_name() -> &'static str { - "ChannelView" - } - - fn render(&mut self, cx: &mut ViewContext) -> AnyElement { - ChildView::new(self.editor.as_any(), cx).into_any() - } - - fn focus_in(&mut self, _: AnyViewHandle, cx: &mut ViewContext) { - if cx.is_self_focused() { - self.acknowledge_buffer_version(cx); - cx.focus(self.editor.as_any()) - } +impl FocusableView for ChannelView { + fn focus_handle(&self, cx: &AppContext) -> gpui::FocusHandle { + self.editor.read(cx).focus_handle(cx) } } impl Item for ChannelView { + type Event = EditorEvent; + fn act_as_type<'a>( &'a self, type_id: TypeId, - self_handle: &'a ViewHandle, + self_handle: &'a View, _: &'a AppContext, - ) -> Option<&'a AnyViewHandle> { + ) -> Option { if type_id == TypeId::of::() { - Some(self_handle) + Some(self_handle.to_any()) } else if type_id == TypeId::of::() { - Some(&self.editor) + Some(self.editor.to_any()) } else { None } } - fn tab_content( - &self, - _: Option, - style: &theme::Tab, - cx: &gpui::AppContext, - ) -> AnyElement { + fn tab_content(&self, _: Option, selected: bool, cx: &WindowContext) -> AnyElement { let label = if let Some(channel) = self.channel(cx) { match ( channel.can_edit_notes(), @@ -276,16 +264,24 @@ impl Item for ChannelView { } else { format!("channel notes (disconnected)") }; - Label::new(label, style.label.to_owned()).into_any() + Label::new(label) + .color(if selected { + Color::Default + } else { + Color::Muted + }) + .into_any_element() } - fn clone_on_split(&self, _: WorkspaceId, cx: &mut ViewContext) -> Option { - Some(Self::new( - self.project.clone(), - self.channel_store.clone(), - self.channel_buffer.clone(), - cx, - )) + fn clone_on_split(&self, _: WorkspaceId, cx: &mut ViewContext) -> Option> { + Some(cx.new_view(|cx| { + Self::new( + self.project.clone(), + self.channel_store.clone(), + self.channel_buffer.clone(), + cx, + ) + })) } fn is_singleton(&self, _cx: &AppContext) -> bool { @@ -307,7 +303,7 @@ impl Item for ChannelView { .update(cx, |editor, cx| Item::set_nav_history(editor, history, cx)) } - fn as_searchable(&self, _: &ViewHandle) -> Option> { + fn as_searchable(&self, _: &View) -> Option> { Some(Box::new(self.editor.clone())) } @@ -315,12 +311,12 @@ impl Item for ChannelView { true } - fn pixel_position_of_cursor(&self, cx: &AppContext) -> Option { + fn pixel_position_of_cursor(&self, cx: &AppContext) -> Option> { self.editor.read(cx).pixel_position_of_cursor(cx) } - fn to_item_events(event: &Self::Event) -> SmallVec<[ItemEvent; 2]> { - editor::Editor::to_item_events(event) + fn to_item_events(event: &EditorEvent, f: impl FnMut(ItemEvent)) { + Editor::to_item_events(event, f) } } @@ -329,7 +325,7 @@ impl FollowableItem for ChannelView { self.remote_id } - fn to_state_proto(&self, cx: &AppContext) -> Option { + fn to_state_proto(&self, cx: &WindowContext) -> Option { let channel_buffer = self.channel_buffer.read(cx); if !channel_buffer.is_connected() { return None; @@ -350,12 +346,12 @@ impl FollowableItem for ChannelView { } fn from_state_proto( - pane: ViewHandle, - workspace: ViewHandle, + pane: View, + workspace: View, remote_id: workspace::ViewId, state: &mut Option, - cx: &mut AppContext, - ) -> Option>>> { + cx: &mut WindowContext, + ) -> Option>>> { let Some(proto::view::Variant::ChannelView(_)) = state else { return None; }; @@ -368,30 +364,28 @@ impl FollowableItem for ChannelView { Some(cx.spawn(|mut cx| async move { let this = open.await?; - let task = this - .update(&mut cx, |this, cx| { - this.remote_id = Some(remote_id); + let task = this.update(&mut cx, |this, cx| { + this.remote_id = Some(remote_id); - if let Some(state) = state.editor { - Some(this.editor.update(cx, |editor, cx| { - editor.apply_update_proto( - &this.project, - proto::update_view::Variant::Editor(proto::update_view::Editor { - selections: state.selections, - pending_selection: state.pending_selection, - scroll_top_anchor: state.scroll_top_anchor, - scroll_x: state.scroll_x, - scroll_y: state.scroll_y, - ..Default::default() - }), - cx, - ) - })) - } else { - None - } - }) - .ok_or_else(|| anyhow!("window was closed"))?; + if let Some(state) = state.editor { + Some(this.editor.update(cx, |editor, cx| { + editor.apply_update_proto( + &this.project, + proto::update_view::Variant::Editor(proto::update_view::Editor { + selections: state.selections, + pending_selection: state.pending_selection, + scroll_top_anchor: state.scroll_top_anchor, + scroll_x: state.scroll_x, + scroll_y: state.scroll_y, + ..Default::default() + }), + cx, + ) + })) + } else { + None + } + })?; if let Some(task) = task { task.await?; @@ -403,9 +397,9 @@ impl FollowableItem for ChannelView { fn add_event_to_update_proto( &self, - event: &Self::Event, + event: &EditorEvent, update: &mut Option, - cx: &AppContext, + cx: &WindowContext, ) -> bool { self.editor .read(cx) @@ -414,7 +408,7 @@ impl FollowableItem for ChannelView { fn apply_update_proto( &mut self, - project: &ModelHandle, + project: &Model, message: proto::update_view::Variant, cx: &mut ViewContext, ) -> gpui::Task> { @@ -429,16 +423,16 @@ impl FollowableItem for ChannelView { }) } - fn should_unfollow_on_event(event: &Self::Event, cx: &AppContext) -> bool { - Editor::should_unfollow_on_event(event, cx) + fn is_project_item(&self, _cx: &WindowContext) -> bool { + false } - fn is_project_item(&self, _cx: &AppContext) -> bool { - false + fn to_follow_event(event: &Self::Event) -> Option { + Editor::to_follow_event(event) } } -struct ChannelBufferCollaborationHub(ModelHandle); +struct ChannelBufferCollaborationHub(Model); impl CollaborationHub for ChannelBufferCollaborationHub { fn collaborators<'a>(&self, cx: &'a AppContext) -> &'a HashMap { diff --git a/crates/collab_ui/src/chat_panel.rs b/crates/collab_ui/src/chat_panel.rs index 5a4dafb6d4..19acb17673 100644 --- a/crates/collab_ui/src/chat_panel.rs +++ b/crates/collab_ui/src/chat_panel.rs @@ -1,6 +1,4 @@ -use crate::{ - channel_view::ChannelView, is_channels_feature_enabled, render_avatar, ChatPanelSettings, -}; +use crate::{channel_view::ChannelView, is_channels_feature_enabled, ChatPanelSettings}; use anyhow::Result; use call::ActiveCall; use channel::{ChannelChat, ChannelChatEvent, ChannelMessageId, ChannelStore}; @@ -9,13 +7,9 @@ use collections::HashMap; use db::kvp::KEY_VALUE_STORE; use editor::Editor; use gpui::{ - actions, - elements::*, - platform::{CursorStyle, MouseButton}, - serde_json, - views::{ItemType, Select, SelectStyle}, - AnyViewHandle, AppContext, AsyncAppContext, Entity, ModelHandle, Subscription, Task, View, - ViewContext, ViewHandle, WeakViewHandle, + actions, div, list, prelude::*, px, serde_json, AnyElement, AppContext, AsyncWindowContext, + ClickEvent, ElementId, EventEmitter, FocusableView, ListOffset, ListScrollEvent, ListState, + Model, Render, Subscription, Task, View, ViewContext, VisualContext, WeakView, }; use language::LanguageRegistry; use menu::Confirm; @@ -23,13 +17,14 @@ use message_editor::MessageEditor; use project::Fs; use rich_text::RichText; use serde::{Deserialize, Serialize}; -use settings::SettingsStore; +use settings::{Settings, SettingsStore}; use std::sync::Arc; -use theme::{IconButton, Theme}; +use theme::ActiveTheme as _; use time::{OffsetDateTime, UtcOffset}; +use ui::{prelude::*, Avatar, Button, Icon, IconButton, Label, TabBar, Tooltip}; use util::{ResultExt, TryFutureExt}; use workspace::{ - dock::{DockPosition, Panel}, + dock::{DockPosition, Panel, PanelEvent}, Workspace, }; @@ -38,29 +33,36 @@ mod message_editor; const MESSAGE_LOADING_THRESHOLD: usize = 50; const CHAT_PANEL_KEY: &'static str = "ChatPanel"; +pub fn init(cx: &mut AppContext) { + cx.observe_new_views(|workspace: &mut Workspace, _| { + workspace.register_action(|workspace, _: &ToggleFocus, cx| { + workspace.toggle_panel_focus::(cx); + }); + }) + .detach(); +} + pub struct ChatPanel { client: Arc, - channel_store: ModelHandle, + channel_store: Model, languages: Arc, - active_chat: Option<(ModelHandle, Subscription)>, - message_list: ListState, - input_editor: ViewHandle, - channel_select: ViewHandle, - ) -> AnyElement