mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-16 00:47:39 +03:00
Notify all views when a theme is selected
This commit is contained in:
parent
b30d0daabf
commit
4c53470800
@ -813,6 +813,16 @@ impl MutableAppContext {
|
||||
.push_back(Effect::ViewNotification { window_id, view_id });
|
||||
}
|
||||
|
||||
pub(crate) fn notify_all_views(&mut self) {
|
||||
let notifications = self
|
||||
.views
|
||||
.keys()
|
||||
.copied()
|
||||
.map(|(window_id, view_id)| Effect::ViewNotification { window_id, view_id })
|
||||
.collect::<Vec<_>>();
|
||||
self.pending_effects.extend(notifications);
|
||||
}
|
||||
|
||||
pub fn dispatch_action<T: 'static + Any>(
|
||||
&mut self,
|
||||
window_id: usize,
|
||||
@ -2087,6 +2097,10 @@ impl<'a, T: View> ViewContext<'a, T> {
|
||||
self.app.notify_view(self.window_id, self.view_id);
|
||||
}
|
||||
|
||||
pub fn notify_all(&mut self) {
|
||||
self.app.notify_all_views();
|
||||
}
|
||||
|
||||
pub fn propagate_action(&mut self) {
|
||||
self.halt_action_dispatch = false;
|
||||
}
|
||||
|
@ -95,16 +95,19 @@ impl ThemePicker {
|
||||
|
||||
fn confirm(&mut self, _: &(), cx: &mut ViewContext<Self>) {
|
||||
if let Some(mat) = self.matches.get(self.selected_index) {
|
||||
let settings_tx = self.settings_tx.clone();
|
||||
if let Ok(theme) = self.registry.get(&mat.string) {
|
||||
cx.foreground()
|
||||
.spawn(async move {
|
||||
settings_tx.lock().await.borrow_mut().theme = theme;
|
||||
let settings_tx = self.settings_tx.clone();
|
||||
cx.spawn(|this, mut cx| async move {
|
||||
let mut settings_tx = settings_tx.lock().await;
|
||||
this.update(&mut cx, |_, cx| {
|
||||
settings_tx.borrow_mut().theme = theme;
|
||||
cx.notify_all();
|
||||
cx.emit(Event::Dismissed);
|
||||
})
|
||||
.detach();
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
}
|
||||
cx.emit(Event::Dismissed);
|
||||
}
|
||||
|
||||
fn select_prev(&mut self, _: &(), cx: &mut ViewContext<Self>) {
|
||||
|
Loading…
Reference in New Issue
Block a user