diff --git a/psst-gui/src/ui/home.rs b/psst-gui/src/ui/home.rs index 91022290..8ea7d916 100644 --- a/psst-gui/src/ui/home.rs +++ b/psst-gui/src/ui/home.rs @@ -27,29 +27,27 @@ pub fn home_widget() -> impl Widget { .with_child(user_top_mixes()) .with_child(recommended_stations()) .with_child(best_of_artists()) - .with_child(simple_title_label("Uniquely yours")) - .with_default_spacer() .with_child(uniquely_yours()) .with_child(your_shows()) .with_child(shows_that_you_might_like()) .with_child(simple_title_label("Your top artists")) - .with_default_spacer() .with_child(user_top_artists_widget()) - .with_default_spacer() .with_child(simple_title_label("Your top tracks")) - .with_default_spacer() .with_child(user_top_tracks_widget()) } fn simple_title_label(title: &str) -> impl Widget { - Label::new(title) + Flex::column() + .with_default_spacer() + .with_child(Label::new(title) .with_text_size(theme::grid(2.5)) .align_left() .padding((theme::grid(1.5), 0.0)) + ) } pub fn made_for_you() -> impl Widget { - Async::new(spinner_widget, loaded_results_widget, error_widget) + Async::new(spinner_widget, loaded_results_widget, || {Empty}) .lens( Ctx::make( AppState::common_ctx, @@ -66,7 +64,7 @@ pub fn made_for_you() -> impl Widget { } pub fn recommended_stations() -> impl Widget { - Async::new(spinner_widget, loaded_results_widget, error_widget) + Async::new(spinner_widget, loaded_results_widget, || {Empty}) .lens( Ctx::make( AppState::common_ctx, @@ -82,8 +80,29 @@ pub fn recommended_stations() -> impl Widget { ) } +fn uniquely_yours_results_widget() -> impl Widget> { + Either::new( + |results: &WithCtx, _| { + results.data.playlists.is_empty() + }, + Empty, + Flex::column().with_default_spacer() + .with_child(Label::new("Uniquely yours") + .with_text_size(theme::grid(2.5)) + .align_left() + .padding((theme::grid(1.5), 0.0)) + ).with_child( + Scroll::new( + Flex::row() + .with_child(playlist_results_widget()) + ) + .align_left(), + ), + ) +} + pub fn uniquely_yours() -> impl Widget { - Async::new(spinner_widget, loaded_results_widget, error_widget) + Async::new(spinner_widget, uniquely_yours_results_widget, || {Empty}) .lens( Ctx::make( AppState::common_ctx, @@ -100,7 +119,7 @@ pub fn uniquely_yours() -> impl Widget { } pub fn user_top_mixes() -> impl Widget { - Async::new(spinner_widget, loaded_results_widget, error_widget) + Async::new(spinner_widget, loaded_results_widget, || {Empty}) .lens( Ctx::make( AppState::common_ctx, @@ -117,7 +136,7 @@ pub fn user_top_mixes() -> impl Widget { } pub fn best_of_artists() -> impl Widget { - Async::new(spinner_widget, loaded_results_widget, error_widget) + Async::new(spinner_widget, loaded_results_widget, || {Empty}) .lens( Ctx::make( AppState::common_ctx, @@ -134,7 +153,7 @@ pub fn best_of_artists() -> impl Widget { } pub fn your_shows() -> impl Widget { - Async::new(spinner_widget, loaded_results_widget, error_widget) + Async::new(spinner_widget, loaded_results_widget, || {Empty}) .lens( Ctx::make( AppState::common_ctx, @@ -151,7 +170,7 @@ pub fn your_shows() -> impl Widget { } pub fn jump_back_in() -> impl Widget { - Async::new(spinner_widget, loaded_results_widget, error_widget) + Async::new(spinner_widget, loaded_results_widget, || {Empty}) .lens( Ctx::make( AppState::common_ctx, @@ -168,7 +187,7 @@ pub fn jump_back_in() -> impl Widget { } pub fn shows_that_you_might_like() -> impl Widget { - Async::new(spinner_widget, loaded_results_widget, error_widget) + Async::new(spinner_widget, loaded_results_widget, || {Empty}) .lens( Ctx::make( AppState::common_ctx, diff --git a/psst-gui/src/ui/playback.rs b/psst-gui/src/ui/playback.rs index 1c2610e7..4515f21b 100644 --- a/psst-gui/src/ui/playback.rs +++ b/psst-gui/src/ui/playback.rs @@ -171,7 +171,6 @@ fn cover_widget(size: f64) -> impl Widget { fn playback_origin_icon(origin: &PlaybackOrigin) -> &'static SvgIcon { match origin { - // TODO add home widget PlaybackOrigin::Home => &icons::HOME, PlaybackOrigin::Library => &icons::HEART, PlaybackOrigin::Queue => &icons::PLAYLIST, diff --git a/psst-gui/src/webapi/client.rs b/psst-gui/src/webapi/client.rs index 56e8774f..61c65276 100644 --- a/psst-gui/src/webapi/client.rs +++ b/psst-gui/src/webapi/client.rs @@ -95,15 +95,15 @@ impl WebApi { } fn put(&self, path: impl Display, base_url: Option<&str>) -> Result { - self.request("GET", base_url.unwrap_or("api.spotify.com"), path) + self.request("PUT", base_url.unwrap_or("api.spotify.com"), path) } fn post(&self, path: impl Display, base_url: Option<&str>) -> Result { - self.request("GET", base_url.unwrap_or("api.spotify.com"), path) + self.request("POST", base_url.unwrap_or("api.spotify.com"), path) } fn delete(&self, path: impl Display, base_url: Option<&str>) -> Result { - self.request("GET", base_url.unwrap_or("api.spotify.com"), path) + self.request("DELETE", base_url.unwrap_or("api.spotify.com"), path) } fn with_retry(f: impl Fn() -> Result) -> Result {