diff --git a/src/dashboard_defs/error.rs b/src/dashboard_defs/error.rs index 3bee985..7c0414b 100644 --- a/src/dashboard_defs/error.rs +++ b/src/dashboard_defs/error.rs @@ -41,7 +41,7 @@ pub fn make_error_window(top_left: Vec2f, size: Vec2f, update_rate: UpdateRate, // This means that the error changed (or disappeared)! if curr_error != cached_error { let skip_update = curr_error.is_none(); - wrapped_individual_state.inner = curr_error.clone(); + wrapped_individual_state.inner.clone_from(curr_error); updater_params.window.set_draw_skipping(skip_update); skip_update } diff --git a/src/spinitron/state.rs b/src/spinitron/state.rs index e1b51e5..f3d9429 100644 --- a/src/spinitron/state.rs +++ b/src/spinitron/state.rs @@ -1,5 +1,7 @@ use std::borrow::Cow; +use chrono::Timelike; + use crate::{ request, texture::TextureCreationInfo, @@ -131,7 +133,7 @@ impl SpinitronStateData { and precaching anything from disk in byte form as well. */ match info.as_ref() { TextureCreationInfo::Path(path) => - Ok(std::fs::read(&path as &str)?), + Ok(std::fs::read(path as &str)?), TextureCreationInfo::Url(url) => Ok(request::get(url)?.as_bytes().to_vec()), @@ -169,6 +171,8 @@ impl SpinitronStateData { self.spin = maybe_new_spin; } + ////////// + /* Step 2: get a maybe new playlist (don't base it on a spin ID, since the spin may not belong to a playlist under automation). */ let maybe_new_playlist = Playlist::get(api_key)?; @@ -180,10 +184,18 @@ impl SpinitronStateData { self.playlist = maybe_new_playlist; } - /* Step 4: get the current show id (based on what's on the - schedule, irrespective of what show was last on). - TODO: should I only do this in the branch above? */ - self.show = Show::get(api_key)?; + ////////// + + let curr_minutes = chrono::Local::now().minute(); + + // Shows can only be scheduled under 30-minute intervals + if curr_minutes == 0 || curr_minutes == 30 { + /* Step 4: get the current show id (based on what's on the + schedule, irrespective of what show was last on). + This is not in the branch above, since the show should + change directly on schedule, not when a new playlist is made. */ + self.show = Show::get(api_key)?; + } Ok(()) }