Checkpoint

Antonio Scandurra created

Change summary

crates/gpui3/src/app.rs               | 18 ++++++++++--------
crates/gpui3/src/app/model_context.rs |  8 ++++----
crates/gpui3/src/window.rs            |  9 +++++----
crates/storybook2/src/collab_panel.rs |  5 ++---
crates/storybook2/src/storybook2.rs   |  5 +----
crates/storybook2/src/workspace.rs    |  2 +-
6 files changed, 23 insertions(+), 24 deletions(-)

Detailed changes

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<dyn Any>) {
+    fn apply_emit_effect(&mut self, emitter: EntityId, event: Box<dyn Any>) {
         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<AppContext> {
 }
 
 pub(crate) enum Effect {
-    Notify(EntityId),
+    Notify {
+        emitter: EntityId,
+    },
     Emit {
-        entity_id: EntityId,
+        emitter: EntityId,
         event: Box<dyn Any + Send + Sync + 'static>,
     },
 }

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),
         });
     }

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<R>(
@@ -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),
         });
     }

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 {

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;

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,