Skip to content

Commit

Permalink
Merge branch 'main' into barebones
Browse files Browse the repository at this point in the history
  • Loading branch information
CaspianA1 committed Jun 5, 2024
2 parents 2ddda41 + 78cf061 commit e6cff50
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/dashboard_defs/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
22 changes: 17 additions & 5 deletions src/spinitron/state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::borrow::Cow;

use chrono::Timelike;

use crate::{
request,
texture::TextureCreationInfo,
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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)?;
Expand All @@ -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(())
}
Expand Down

0 comments on commit e6cff50

Please sign in to comment.