Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Move CallFactory into AppState
Piotr Osiewicz7e7a778d1169
diff --git a/crates/workspace2/src/workspace2.rs b/crates/workspace2/src/workspace2.rsindex 754988a6057..e1e79c4d3e5 100644--- a/crates/workspace2/src/workspace2.rs+++ b/crates/workspace2/src/workspace2.rs@@ -207,10 +207,9 @@ pub fn init_settings(cx: &mut AppContext) {ItemSettings::register(cx);}-pub fn init(app_state: Arc<AppState>, cx: &mut AppContext, call_factory: CallFactory) {+pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {init_settings(cx);notifications::init(cx);- cx.set_global(call_factory);// cx.add_global_action({// let app_state = Arc::downgrade(&app_state);// move |_: &Open, cx: &mut AppContext| {@@ -304,6 +303,7 @@ pub struct AppState {pub user_store: Model<UserStore>,pub workspace_store: Model<WorkspaceStore>,pub fs: Arc<dyn fs2::Fs>,+ pub call_factory: CallFactory,pub build_window_options:fn(Option<WindowBounds>, Option<Uuid>, &mut AppContext) -> WindowOptions,pub node_runtime: Arc<dyn NodeRuntime>,@@ -653,7 +653,6 @@ impl Workspace {];cx.defer(|this, cx| this.update_window_title(cx));- let call_factory = cx.global::<CallFactory>();Workspace {window_self: window_handle,weak_self: weak_handle.clone(),@@ -677,7 +676,7 @@ impl Workspace {last_leaders_by_pane: Default::default(),window_edited: false,- call_handler: call_factory(weak_handle.clone(), cx),+ call_handler: (app_state.call_factory)(weak_handle.clone(), cx),database_id: workspace_id,app_state,_observe_current_user,@@ -2784,8 +2783,9 @@ impl Workspace {} else {None};+ let room_id = self.call_handler.room_id(cx)?;self.app_state().workspace_store.update(cx, |store, cx| {- store.update_followers(project_id, update, cx)+ store.update_followers(project_id, room_id, update, cx)})}@@ -3825,15 +3825,10 @@ impl WorkspaceStore {pub fn update_followers(&self,project_id: Option<u64>,+ room_id: u64,update: proto::update_followers::Variant,cx: &AppContext,) -> Option<()> {- let room_id = self.workspaces.iter().next().and_then(|workspace| {- workspace- .read_with(cx, |this, cx| this.call_handler.room_id(cx))- .log_err()- .flatten()- })?;let follower_ids: Vec<_> = self.followers.iter()diff --git a/crates/zed2/src/main.rs b/crates/zed2/src/main.rsindex 62d337a716d..b0a03d8684d 100644--- a/crates/zed2/src/main.rs+++ b/crates/zed2/src/main.rs@@ -180,6 +180,7 @@ fn main() {user_store,fs,build_window_options,+ call_factory: call::Call::new,// background_actions: todo!("ask Mikayla"),workspace_store,node_runtime,@@ -189,7 +190,7 @@ fn main() {// audio::init(Assets, cx);auto_update::init(http.clone(), client::ZED_SERVER_URL.clone(), cx);- workspace::init(app_state.clone(), cx, call::Call::new);+ workspace::init(app_state.clone(), cx);// recent_projects::init(cx);go_to_line::init(cx);