Skip to content

Commit

Permalink
fix #461: No playlist on psst-gui and failed to read json error (#464)
Browse files Browse the repository at this point in the history
Makes playlist images an optional Vector.
  • Loading branch information
nicolasf authored Apr 1, 2024
1 parent 0cb4f69 commit 37d8da1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions psst-gui/src/data/playlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ pub struct PlaylistRemoveTrack {
pub struct Playlist {
pub id: Arc<str>,
pub name: Arc<str>,
pub images: Vector<Image>,
#[serde(skip_serializing_if="Option::is_none")]
pub images: Option<Vector<Image>>,
pub description: Arc<str>,
#[serde(rename = "tracks")]
#[serde(deserialize_with = "deserialize_track_count")]
Expand All @@ -45,7 +46,9 @@ impl Playlist {
}

pub fn image(&self, width: f64, height: f64) -> Option<&Image> {
Image::at_least_of_size(&self.images, width, height)
self.images.as_ref().and_then(|images| {
Image::at_least_of_size(images, width, height)
})
}

pub fn url(&self) -> String {
Expand Down

0 comments on commit 37d8da1

Please sign in to comment.