From 623ecfc20c202dd953285c23d861da443105ec88 Mon Sep 17 00:00:00 2001 From: "hinto.janai" Date: Wed, 27 Mar 2024 17:14:40 -0400 Subject: [PATCH 1/2] gui: calculate queue time after receiving new `Collection` --- gui/src/func/gui.rs | 15 +++++++++++++++ gui/src/ui/update.rs | 8 +------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/gui/src/func/gui.rs b/gui/src/func/gui.rs index d2aa6384..f5f3cae3 100644 --- a/gui/src/func/gui.rs +++ b/gui/src/func/gui.rs @@ -71,6 +71,9 @@ impl Gui { // state keys are not referencing invalid keys. self.state_restore .update_state(&mut self.state, &self.collection); + + // Update queue time. + self.calculate_and_set_queue_time(); } // Sets the [`egui::Ui`]'s `Visual` from our current `Settings` @@ -394,4 +397,16 @@ impl Gui { None } } + + /// Given the current [`AudioState`] queue, calculate the + /// total runtime and set the ephemeral state to reflect it. + pub fn calculate_and_set_queue_time(&mut self) { + self.queue_time = self + .audio_state + .queue + .iter() + .map(|k| self.collection.songs[k].runtime.inner() as u64) + .sum::() + .into(); + } } diff --git a/gui/src/ui/update.rs b/gui/src/ui/update.rs index 3a65ebf4..d925e851 100644 --- a/gui/src/ui/update.rs +++ b/gui/src/ui/update.rs @@ -94,13 +94,7 @@ impl eframe::App for Gui { if self.kernel_returned && queue_diff && /* needed to prevent panic */ !self.resetting_collection { - self.queue_time = self - .audio_state - .queue - .iter() - .map(|k| self.collection.songs[k].runtime.inner() as u64) - .sum::() - .into(); + self.calculate_and_set_queue_time(); } // Auto-save state. if (self.kernel_returned && !self.resetting_collection) From 8d7e26d55e7677e3d38d6c51c51683830e9cbd61 Mon Sep 17 00:00:00 2001 From: "hinto.janai" Date: Wed, 27 Mar 2024 17:25:05 -0400 Subject: [PATCH 2/2] update `CHANGELOG.md` --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8cf64c2..5106754f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,10 @@ Types of changes: # Festival GUI Unreleased ## Added -- `QueueRepeat` mode to repeat queue but start paused ([#90](https://github.com/hinto-janai/festival/pull/90)) +- `QueueRepeat` mode that repeats the queue but starts paused ([#90](https://github.com/hinto-janai/festival/pull/90)) + +## Fixed +* Queue tab: total runtime being `0 seconds` on restart ([#96](https://github.com/hinto-janai/festival/pull/96)) ---