feat: 1:1 For You, My Collection, Concerts, Books & Podcasts, WordsCardFullscreen and release v0.1.2
This commit is contained in:
parent
8e7ec9142f
commit
e9aa253f72
12 changed files with 4393 additions and 593 deletions
101
src/app/state.rs
101
src/app/state.rs
|
|
@ -248,6 +248,12 @@ pub enum AppAction {
|
|||
title: String,
|
||||
seeds: Vec<String>,
|
||||
},
|
||||
StartVibeStation {
|
||||
title: String,
|
||||
seeds: Vec<String>,
|
||||
},
|
||||
RefreshConcerts,
|
||||
RefreshNonMusic,
|
||||
ApplyVibeSettings {
|
||||
mood: Option<String>,
|
||||
activity: Option<String>,
|
||||
|
|
@ -387,6 +393,7 @@ pub(crate) enum ApiEvent {
|
|||
AccountLoaded(Result<UserAccount, String>),
|
||||
LandingLoaded(LandingData),
|
||||
ConcertsLoaded(Vec<ConcertItem>),
|
||||
NonMusicLoaded(Vec<NonMusicSection>, Vec<AlbumSummary>),
|
||||
SearchHistoryLoaded(Vec<String>),
|
||||
LikedTracksLoaded(Vec<Track>),
|
||||
FavoriteFiltersLoaded(Vec<TrackFilterChip>),
|
||||
|
|
@ -474,6 +481,9 @@ pub struct AppState {
|
|||
pub account: Option<UserAccount>,
|
||||
pub landing: LandingData,
|
||||
pub concerts: Vec<ConcertItem>,
|
||||
pub concerts_loading: bool,
|
||||
pub non_music_sections: Vec<NonMusicSection>,
|
||||
pub non_music_loading: bool,
|
||||
pub liked_tracks: Vec<Track>,
|
||||
pub liked_ids: HashSet<String>,
|
||||
pub disliked_ids: HashSet<String>,
|
||||
|
|
@ -627,6 +637,9 @@ impl AppState {
|
|||
account: None,
|
||||
landing: LandingData::default(),
|
||||
concerts: Vec::new(),
|
||||
concerts_loading: false,
|
||||
non_music_sections: Vec::new(),
|
||||
non_music_loading: false,
|
||||
liked_tracks: Vec::new(),
|
||||
liked_ids: HashSet::new(),
|
||||
disliked_ids: HashSet::new(),
|
||||
|
|
@ -774,6 +787,9 @@ impl AppState {
|
|||
account,
|
||||
landing,
|
||||
concerts: Vec::new(),
|
||||
concerts_loading: false,
|
||||
non_music_sections: Vec::new(),
|
||||
non_music_loading: false,
|
||||
liked_tracks,
|
||||
liked_ids,
|
||||
disliked_ids: HashSet::new(),
|
||||
|
|
@ -1289,9 +1305,16 @@ impl AppState {
|
|||
let api = self.api.clone();
|
||||
let tx = self.tx_api.clone();
|
||||
self.runtime.spawn(async move {
|
||||
if let Ok(concerts) = api.fetch_concerts_feed().await {
|
||||
let _ = tx.send(ApiEvent::ConcertsLoaded(concerts));
|
||||
}
|
||||
let concerts = api.fetch_concerts_feed().await.unwrap_or_default();
|
||||
let _ = tx.send(ApiEvent::ConcertsLoaded(concerts));
|
||||
});
|
||||
}
|
||||
{
|
||||
let api = self.api.clone();
|
||||
let tx = self.tx_api.clone();
|
||||
self.runtime.spawn(async move {
|
||||
let (sections, albums) = api.fetch_non_music_landing().await.unwrap_or_default();
|
||||
let _ = tx.send(ApiEvent::NonMusicLoaded(sections, albums));
|
||||
});
|
||||
}
|
||||
{
|
||||
|
|
@ -1637,12 +1660,53 @@ impl AppState {
|
|||
}
|
||||
});
|
||||
}
|
||||
Route::Concerts => {
|
||||
self.detail_loading = false;
|
||||
if self.concerts.is_empty() && !self.concerts_loading {
|
||||
self.refresh_concerts();
|
||||
}
|
||||
}
|
||||
Route::Podcasts => {
|
||||
self.detail_loading = false;
|
||||
if self.non_music_sections.is_empty() && !self.non_music_loading {
|
||||
self.refresh_non_music();
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
self.detail_loading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn refresh_concerts(&mut self) {
|
||||
self.concerts_loading = true;
|
||||
let api = self.api.clone();
|
||||
let tx = self.tx_api.clone();
|
||||
self.runtime.spawn(async move {
|
||||
let concerts = api.fetch_concerts_feed().await.unwrap_or_default();
|
||||
let _ = tx.send(ApiEvent::ConcertsLoaded(concerts));
|
||||
});
|
||||
}
|
||||
|
||||
pub fn refresh_non_music(&mut self) {
|
||||
self.non_music_loading = true;
|
||||
let api = self.api.clone();
|
||||
let tx = self.tx_api.clone();
|
||||
self.runtime.spawn(async move {
|
||||
let (sections, albums) = api.fetch_non_music_landing().await.unwrap_or_default();
|
||||
let _ = tx.send(ApiEvent::NonMusicLoaded(sections, albums));
|
||||
});
|
||||
if self.api.has_token() {
|
||||
let api = self.api.clone();
|
||||
let tx = self.tx_api.clone();
|
||||
self.runtime.spawn(async move {
|
||||
if let Ok(shelf) = api.fetch_bookshelf_liked().await {
|
||||
let _ = tx.send(ApiEvent::BookshelfLoaded(shelf));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn launch_oauth_login(&mut self) {
|
||||
self.show_toast(self.i18n().toast_opening_oauth());
|
||||
let tx = self.tx_api.clone();
|
||||
|
|
@ -1717,6 +1781,12 @@ impl AppState {
|
|||
self.show_toast(t.toast_welcome(&acc.display_name));
|
||||
self.account = Some(acc);
|
||||
self.ensure_words_for_current_track();
|
||||
if self.concerts.is_empty() && !self.concerts_loading {
|
||||
self.refresh_concerts();
|
||||
}
|
||||
if self.non_music_sections.is_empty() && !self.non_music_loading {
|
||||
self.refresh_non_music();
|
||||
}
|
||||
}
|
||||
ApiEvent::AccountLoaded(Err(e)) => {
|
||||
self.show_toast(if t.is_ru() {
|
||||
|
|
@ -1726,7 +1796,19 @@ impl AppState {
|
|||
});
|
||||
}
|
||||
ApiEvent::ConcertsLoaded(concerts) => {
|
||||
self.concerts = concerts;
|
||||
self.concerts_loading = false;
|
||||
if !concerts.is_empty() || self.concerts.is_empty() {
|
||||
self.concerts = concerts;
|
||||
}
|
||||
}
|
||||
ApiEvent::NonMusicLoaded(sections, albums) => {
|
||||
self.non_music_loading = false;
|
||||
if !sections.is_empty() {
|
||||
self.non_music_sections = sections;
|
||||
}
|
||||
if !albums.is_empty() {
|
||||
self.landing.podcasts = albums;
|
||||
}
|
||||
}
|
||||
ApiEvent::SearchHistoryLoaded(hist) => {
|
||||
self.config.search_history = hist;
|
||||
|
|
@ -1777,6 +1859,10 @@ impl AppState {
|
|||
self.queue_index = 0;
|
||||
}
|
||||
}
|
||||
let mut data = data;
|
||||
if data.podcasts.is_empty() && !self.landing.podcasts.is_empty() {
|
||||
data.podcasts = self.landing.podcasts.clone();
|
||||
}
|
||||
self.landing = data;
|
||||
}
|
||||
ApiEvent::LikedTracksLoaded(tracks) => {
|
||||
|
|
@ -2419,7 +2505,12 @@ impl AppState {
|
|||
}
|
||||
AppAction::ActivateWheelItem(item) => self.activate_wheel_item(item),
|
||||
AppAction::ReshuffleWheel => self.reshuffle_wheel(),
|
||||
AppAction::StartVibeBySeeds { title, seeds } => self.start_vibe_by_seeds(title, seeds),
|
||||
AppAction::StartVibeBySeeds { title, seeds }
|
||||
| AppAction::StartVibeStation { title, seeds } => {
|
||||
self.start_vibe_by_seeds(title, seeds);
|
||||
}
|
||||
AppAction::RefreshConcerts => self.refresh_concerts(),
|
||||
AppAction::RefreshNonMusic => self.refresh_non_music(),
|
||||
AppAction::ApplyVibeSettings {
|
||||
mood,
|
||||
activity,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue