BlueGit

ict rusty-teams

fix(chat): big emojis play when the window is in front

- gpui only advances frames while the window is active, but the two appear loops counted down in the background
- The loops now start once the window is active and start over after it lost focus

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-11-11 · 2 weeks ago

Hash
e2999d8e2dc2a555d640da42b50877662a569da4
Parent
83e3a114
1 file changed +8 −2
crates/app/src/views/jumbo_emoji.rs +8 −2
@@ -51,10 +51,16 @@ impl RenderOnce for JumboEmoticon {
51 51 loops: APPEAR_LOOPS,
52 52 });
53 53 let now = Instant::now();
54 let active = window.is_window_active();
54 55 let (started, loops) = playback.update(cx, |playback, _| {
55 (*playback.started.get_or_insert(now), playback.loops)
56 if !active {
57 playback.started = None;
58 }
59 let started = active.then(|| *playback.started.get_or_insert(now));
60 (started, playback.loops)
56 61 });
57 let playing = now.duration_since(started) < resolved.loop_duration() * loops;
62 let playing = started
63 .is_some_and(|started| now.duration_since(started) < resolved.loop_duration() * loops);
58 64 let image = if playing {
59 65 images.animated.clone()
60 66 } else {
@@ -51,10 +51,16 @@ impl RenderOnce for JumboEmoticon {
51 loops: APPEAR_LOOPS,
51 loops: APPEAR_LOOPS,
52 });
52 });
53 let now = Instant::now();
53 let now = Instant::now();
54 let active = window.is_window_active();
54 let (started, loops) = playback.update(cx, |playback, _| {
55 let (started, loops) = playback.update(cx, |playback, _| {
55 (*playback.started.get_or_insert(now), playback.loops)
56 if !active {
57 playback.started = None;
58 }
59 let started = active.then(|| *playback.started.get_or_insert(now));
60 (started, playback.loops)
56 });
61 });
57 let playing = now.duration_since(started) < resolved.loop_duration() * loops;
62 let playing = started
63 .is_some_and(|started| now.duration_since(started) < resolved.loop_duration() * loops);
58 let image = if playing {
64 let image = if playing {
59 images.animated.clone()
65 images.animated.clone()
60 } else {
66 } else {