Skip to content

Commit

Permalink
Fixed registration of a callback that supposed to remove 'new' class …
Browse files Browse the repository at this point in the history
…from clients
  • Loading branch information
Elvyria committed Mar 22, 2024
1 parent 1efaeb7 commit cb5ab5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<Instant> = 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
Expand Down

0 comments on commit cb5ab5a

Please sign in to comment.