Checkpoint
This commit is contained in:
@@ -146,6 +146,7 @@ impl AppContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn flush_effects(&mut self) {
|
fn flush_effects(&mut self) {
|
||||||
|
dbg!("flush effects");
|
||||||
while let Some(effect) = self.pending_effects.pop_front() {
|
while let Some(effect) = self.pending_effects.pop_front() {
|
||||||
match effect {
|
match effect {
|
||||||
Effect::Notify(entity_id) => self.apply_notify_effect(entity_id),
|
Effect::Notify(entity_id) => self.apply_notify_effect(entity_id),
|
||||||
|
|||||||
@@ -67,6 +67,12 @@ impl AsyncWindowContext {
|
|||||||
pub fn update<R>(&self, update: impl FnOnce(&mut WindowContext) -> R) -> Result<R> {
|
pub fn update<R>(&self, update: impl FnOnce(&mut WindowContext) -> R) -> Result<R> {
|
||||||
self.app.update_window(self.window, update)
|
self.app.update_window(self.window, update)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn on_next_frame(&mut self, f: impl FnOnce(&mut WindowContext) + Send + 'static) {
|
||||||
|
self.app
|
||||||
|
.update_window(self.window, |cx| cx.on_next_frame(f))
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Context for AsyncWindowContext {
|
impl Context for AsyncWindowContext {
|
||||||
|
|||||||
@@ -75,12 +75,11 @@ impl<S: Send + Sync + 'static> Element for Img<S> {
|
|||||||
let corner_radii = style.corner_radii.to_pixels(bounds, cx.rem_size());
|
let corner_radii = style.corner_radii.to_pixels(bounds, cx.rem_size());
|
||||||
cx.paint_image(bounds, corner_radii, order, data, self.grayscale)?;
|
cx.paint_image(bounds, corner_radii, order, data, self.grayscale)?;
|
||||||
} else {
|
} else {
|
||||||
cx.spawn(|view, mut cx| async move {
|
cx.spawn(|_, mut cx| async move {
|
||||||
if image_future.await.log_err().is_some() {
|
if image_future.await.log_err().is_some() {
|
||||||
view.update(&mut cx, |_, cx| {
|
cx.on_next_frame(|cx| {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})
|
});
|
||||||
.ok();
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.detach()
|
.detach()
|
||||||
|
|||||||
Reference in New Issue
Block a user