diff --git a/crates/gpui3/src/app.rs b/crates/gpui3/src/app.rs index 17676ca645..4f0670fa9a 100644 --- a/crates/gpui3/src/app.rs +++ b/crates/gpui3/src/app.rs @@ -148,8 +148,8 @@ impl AppContext { fn flush_effects(&mut self) { while let Some(effect) = self.pending_effects.pop_front() { match effect { - Effect::Notify(entity_id) => self.apply_notify_effect(entity_id), - Effect::Emit { entity_id, event } => self.apply_emit_effect(entity_id, event), + Effect::Notify { emitter } => self.apply_notify_effect(emitter), + Effect::Emit { emitter, event } => self.apply_emit_effect(emitter, event), } } @@ -171,16 +171,16 @@ impl AppContext { } } - fn apply_notify_effect(&mut self, updated_entity: EntityId) { + fn apply_notify_effect(&mut self, emitter: EntityId) { self.observers .clone() - .retain(&updated_entity, |handler| handler(self)); + .retain(&emitter, |handler| handler(self)); } - fn apply_emit_effect(&mut self, updated_entity: EntityId, event: Box) { + fn apply_emit_effect(&mut self, emitter: EntityId, event: Box) { self.event_handlers .clone() - .retain(&updated_entity, |handler| handler(&event, self)); + .retain(&emitter, |handler| handler(&event, self)); } pub fn to_async(&self) -> AsyncAppContext { @@ -380,9 +380,11 @@ impl MainThread { } pub(crate) enum Effect { - Notify(EntityId), + Notify { + emitter: EntityId, + }, Emit { - entity_id: EntityId, + emitter: EntityId, event: Box, }, } diff --git a/crates/gpui3/src/app/model_context.rs b/crates/gpui3/src/app/model_context.rs index 56e10e489b..d646bd4611 100644 --- a/crates/gpui3/src/app/model_context.rs +++ b/crates/gpui3/src/app/model_context.rs @@ -86,16 +86,16 @@ impl<'a, T: Send + Sync + 'static> ModelContext<'a, T> { } pub fn notify(&mut self) { - self.app - .pending_effects - .push_back(Effect::Notify(self.entity_id)); + self.app.pending_effects.push_back(Effect::Notify { + emitter: self.entity_id, + }); } } impl<'a, T: EventEmitter + Send + Sync + 'static> ModelContext<'a, T> { pub fn emit(&mut self, event: T::Event) { self.app.pending_effects.push_back(Effect::Emit { - entity_id: self.entity_id, + emitter: self.entity_id, event: Box::new(event), }); } diff --git a/crates/gpui3/src/window.rs b/crates/gpui3/src/window.rs index 1f1f87afac..fefa617a0b 100644 --- a/crates/gpui3/src/window.rs +++ b/crates/gpui3/src/window.rs @@ -966,7 +966,9 @@ impl<'a, 'w, S: Send + Sync + 'static> ViewContext<'a, 'w, S> { self.window_cx .app .pending_effects - .push_back(Effect::Notify(self.entity_id)); + .push_back(Effect::Notify { + emitter: self.entity_id, + }); } pub fn run_on_main( @@ -1016,9 +1018,8 @@ impl<'a, 'w, S: Send + Sync + 'static> ViewContext<'a, 'w, S> { impl<'a, 'w, S: EventEmitter + Send + Sync + 'static> ViewContext<'a, 'w, S> { pub fn emit(&mut self, event: S::Event) { - let entity_id = self.entity_id; - self.app.pending_effects.push_back(Effect::Emit { - entity_id, + self.window_cx.app.pending_effects.push_back(Effect::Emit { + emitter: self.entity_id, event: Box::new(event), }); } diff --git a/crates/storybook2/src/collab_panel.rs b/crates/storybook2/src/collab_panel.rs index 9d529f4a47..2f733c1b76 100644 --- a/crates/storybook2/src/collab_panel.rs +++ b/crates/storybook2/src/collab_panel.rs @@ -1,8 +1,7 @@ use crate::theme::{theme, Theme}; use gpui3::{ - div, img, svg, view, AppContext, Context, Element, ElementId, IdentifiedElement, - IntoAnyElement, ParentElement, ScrollState, SharedString, StyleHelpers, Styled, View, - ViewContext, WindowContext, + div, svg, view, AppContext, Context, Element, ElementId, IntoAnyElement, ParentElement, + ScrollState, SharedString, StyleHelpers, Styled, View, ViewContext, WindowContext, }; pub struct CollabPanel { diff --git a/crates/storybook2/src/storybook2.rs b/crates/storybook2/src/storybook2.rs index 1c819328fa..719ce348ea 100644 --- a/crates/storybook2/src/storybook2.rs +++ b/crates/storybook2/src/storybook2.rs @@ -1,13 +1,10 @@ #![allow(dead_code, unused_variables)] use assets::Assets; -use gpui3::{ - div, px, size, Bounds, Element, StyleHelpers, WindowBounds, WindowContext, WindowOptions, -}; +use gpui3::{px, size, Bounds, WindowBounds, WindowOptions}; use log::LevelFilter; use simplelog::SimpleLogger; use std::sync::Arc; -use themes::rose_pine; use workspace::workspace; mod assets; diff --git a/crates/storybook2/src/workspace.rs b/crates/storybook2/src/workspace.rs index c2b8eab759..e902df6565 100644 --- a/crates/storybook2/src/workspace.rs +++ b/crates/storybook2/src/workspace.rs @@ -1,7 +1,7 @@ use crate::{ collab_panel::{collab_panel, CollabPanel}, theme::{theme, themed}, - themes::{rose_pine, rose_pine_dawn}, + themes::rose_pine, }; use gpui3::{ div, img, svg, view, Context, Element, ParentElement, RootView, StyleHelpers, Styled, View,