diff --git a/CHANGELOG.md b/CHANGELOG.md index 89b3e91..68f0bf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). +## [Unreleased] + +### Fixed +- Animation no longer plays multiple times when a new client is addded. + ## [0.2.0] - 2024-03-21 ### Added @@ -37,6 +42,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - List of sinks will now grow from bottom to top if window is anchored to bottom. - Minimal `rustc` version for compilation is now `1.75.0` due to [FileTimes](https://doc.rust-lang.org/std/fs/struct.FileTimes.html) stabilization. +[unreleased]: https://github.com/Elvyria/Mixxc/compare/0.2.0...HEAD [0.2.0]: https://github.com/Elvyria/Mixxc/compare/0.1.10...0.2.0 [0.1.10]: https://github.com/Elvyria/Mixxc/compare/0.1.9...0.1.10 [0.1.9]: https://github.com/Elvyria/Mixxc/compare/0.1.8...0.1.9 diff --git a/src/app.rs b/src/app.rs index 364e38c..5df5393 100644 --- a/src/app.rs +++ b/src/app.rs @@ -5,6 +5,7 @@ use std::sync::Arc; use std::time::{Duration, Instant}; use relm4::gtk; +use relm4::once_cell::sync::OnceCell; use relm4::{ComponentParts, ComponentSender, Component, RelmWidgetExt, FactorySender}; use relm4::factory::FactoryVecDeque; use relm4::prelude::{DynamicIndex, FactoryComponent}; @@ -236,18 +237,18 @@ impl FactoryComponent for Slider { move |_| fill.queue_resize() }); - widgets.root.connect_realize(|root| { + widgets.root.add_tick_callback({ const DELAY: Duration = Duration::from_millis(500); - let before: Instant = Instant::now(); + let before: OnceCell = OnceCell::new(); - root.add_tick_callback(move |root, _| { - if Instant::now() - before < DELAY { + move |root, _| { + if Instant::now() - *before.get_or_init(Instant::now) < DELAY { return ControlFlow::Continue } root.remove_css_class("new"); ControlFlow::Break - }); + } }); widgets