Skip to content

Commit

Permalink
Homepage revamp (#520)
Browse files Browse the repository at this point in the history
* Added "Made For You" section and other personalized home content similar to the Spotify desktop client

* Unified and resized playlist, artist, and album widgets

* Cached user info

* Sanitized HTML in descriptions and truncated text to three liens

---------

Co-authored-by: SO9010 <SO9010sami@gmail.com>
Co-authored-by: Jackson Goode <jacksongoode@proton.me>
  • Loading branch information
3 people authored Sep 23, 2024
1 parent 0cd9904 commit 4dfa43d
Show file tree
Hide file tree
Showing 18 changed files with 1,558 additions and 294 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ cache
.env
*.iml
rust-toolchain
*.ico
*.ico
192 changes: 192 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion psst-gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ souvlaki = { version = "0.7.3", default-features = false, features = [
"use_zbus",
] }
webbrowser = { version = "1.0.1" }
sanitize_html = "0.8.1"
[target.'cfg(windows)'.build-dependencies]
winres = { version = "0.1.12" }
image = { version = "0.25.2" }
Expand All @@ -68,4 +69,4 @@ category = "Music"
short_description = "Fast Spotify client with native GUI"
long_description = """
Small and efficient graphical music player for Spotify network.
"""
"""
2 changes: 1 addition & 1 deletion psst-gui/src/data/album.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl Album {
self.release_date
.as_ref()
.map(|date| date.format(format).expect("invalid format"))
.unwrap_or_else(|| '-'.to_string())
.unwrap_or_default()
}

pub fn image(&self, width: f64, height: f64) -> Option<&Image> {
Expand Down
41 changes: 34 additions & 7 deletions psst-gui/src/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub use crate::data::{
show::{Episode, EpisodeId, EpisodeLink, Show, ShowDetail, ShowEpisodes, ShowLink},
slider_scroll_scale::SliderScrollScale,
track::{AudioAnalysis, Track, TrackId},
user::UserProfile,
user::{PublicUser, UserProfile},
utils::{Cached, Float64, Image, Page},
};

Expand All @@ -79,7 +79,7 @@ pub struct AppState {
pub show_detail: ShowDetail,
pub library: Arc<Library>,
pub common_ctx: Arc<CommonCtx>,
pub personalized: Personalized,
pub home_detail: HomeDetail,
pub alerts: Vector<Alert>,
pub finder: Finder,
pub added_queue: Vector<QueueEntry>,
Expand Down Expand Up @@ -131,6 +131,18 @@ impl AppState {
knobs: Default::default(),
results: Promise::Empty,
},
home_detail: HomeDetail {
made_for_you: Promise::Empty,
user_top_mixes: Promise::Empty,
best_of_artists: Promise::Empty,
recommended_stations: Promise::Empty,
your_shows: Promise::Empty,
shows_that_you_might_like: Promise::Empty,
uniquely_yours: Promise::Empty,
jump_back_in: Promise::Empty,
user_top_tracks: Promise::Empty,
user_top_artists: Promise::Empty,
},
album_detail: AlbumDetail {
album: Promise::Empty,
},
Expand All @@ -150,9 +162,6 @@ impl AppState {
},
library,
common_ctx,
personalized: Personalized {
made_for_you: Promise::Empty,
},
alerts: Vector::new(),
finder: Finder::new(),
}
Expand Down Expand Up @@ -512,8 +521,26 @@ impl CommonCtx {
pub type WithCtx<T> = Ctx<Arc<CommonCtx>, T>;

#[derive(Clone, Data, Lens)]
pub struct Personalized {
pub made_for_you: Promise<Vector<Playlist>>,
pub struct HomeDetail {
pub made_for_you: Promise<MixedView>,
pub user_top_mixes: Promise<MixedView>,
pub best_of_artists: Promise<MixedView>,
pub recommended_stations: Promise<MixedView>,
pub uniquely_yours: Promise<MixedView>,
pub your_shows: Promise<MixedView>,
pub shows_that_you_might_like: Promise<MixedView>,
pub jump_back_in: Promise<MixedView>,
pub user_top_tracks: Promise<Vector<Arc<Track>>>,
pub user_top_artists: Promise<Vector<Artist>>,
}

#[derive(Clone, Data, Lens)]
pub struct MixedView {
pub title: Arc<str>,
pub playlists: Vector<Playlist>,
pub artists: Vector<Artist>,
pub albums: Vector<Arc<Album>>,
pub shows: Vector<Arc<Show>>,
}

static ALERT_ID: AtomicUsize = AtomicUsize::new(0);
Expand Down
Loading

0 comments on commit 4dfa43d

Please sign in to comment.