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)) --- 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)