chore(release): v0.1.4 - 1:1 SyncLyrics, scroll isolation, object-fit cover, Concerts icon, friends' likes & duplicate-title albums
This commit is contained in:
parent
0b2561503f
commit
f063382410
21 changed files with 1287 additions and 288 deletions
|
|
@ -1461,8 +1461,24 @@ impl AppState {
|
|||
let api_c = api.clone();
|
||||
let tx_c = tx.clone();
|
||||
rt.spawn(async move {
|
||||
let mut merged = Vec::new();
|
||||
let mut seen = HashSet::new();
|
||||
if let Ok(pls) = api_c.fetch_user_playlists(uid).await {
|
||||
let _ = tx_c.send(ApiEvent::UserPlaylistsLoaded(pls));
|
||||
for pl in pls {
|
||||
if seen.insert((pl.owner_uid.clone(), pl.kind.clone())) {
|
||||
merged.push(pl);
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Ok(liked_pls) = api_c.fetch_liked_playlists(uid).await {
|
||||
for pl in liked_pls {
|
||||
if seen.insert((pl.owner_uid.clone(), pl.kind.clone())) {
|
||||
merged.push(pl);
|
||||
}
|
||||
}
|
||||
}
|
||||
if !merged.is_empty() {
|
||||
let _ = tx_c.send(ApiEvent::UserPlaylistsLoaded(merged));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -1779,7 +1795,10 @@ impl AppState {
|
|||
match ev {
|
||||
ApiEvent::AccountLoaded(Ok(acc)) => {
|
||||
self.show_toast(t.toast_welcome(&acc.display_name));
|
||||
let uid = acc.uid;
|
||||
self.account = Some(acc);
|
||||
normalize_pins(&mut self.config.pinned_items, Some(uid), t.is_ru());
|
||||
self.save_config();
|
||||
self.ensure_words_for_current_track();
|
||||
if self.concerts.is_empty() && !self.concerts_loading {
|
||||
self.refresh_concerts();
|
||||
|
|
@ -1901,20 +1920,8 @@ impl AppState {
|
|||
self.bookshelf_items = items;
|
||||
}
|
||||
ApiEvent::PinsLoaded(mut pins) => {
|
||||
let mut seen_likes = false;
|
||||
pins.retain(|p| {
|
||||
let is_likes = p.kind == "likes"
|
||||
|| p.id == "likes"
|
||||
|| p.title == "Мне нравится"
|
||||
|| p.title == "My Favorites";
|
||||
if is_likes {
|
||||
if seen_likes {
|
||||
return false;
|
||||
}
|
||||
seen_likes = true;
|
||||
}
|
||||
true
|
||||
});
|
||||
let my_uid = self.account.as_ref().map(|a| a.uid);
|
||||
normalize_pins(&mut pins, my_uid, t.is_ru());
|
||||
self.config.pinned_items = pins;
|
||||
self.save_config();
|
||||
}
|
||||
|
|
@ -3039,6 +3046,26 @@ pub fn is_newer_version(remote: &str, current: &str) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
/// Normalize pinned items so only the signed-in user's own `kind == "3"` (`{my_uid}:3`)
|
||||
/// collapses into system `kind: "likes", id: "likes"`, while friends' `"Мне нравится"` playlists
|
||||
/// (`{friend_uid}:3`) are ALWAYS preserved as distinct `"playlist"` pins!
|
||||
fn normalize_pins(pins: &mut Vec<PinnedItem>, my_uid: Option<u64>, ru: bool) {
|
||||
if let Some(uid) = my_uid {
|
||||
let my_likes_id = format!("{}:3", uid);
|
||||
let likes_title = if ru { "Мне нравится" } else { "My Favorites" };
|
||||
for p in pins.iter_mut() {
|
||||
if p.kind == "playlist" && p.id == my_likes_id {
|
||||
p.id = "likes".into();
|
||||
p.kind = "likes".into();
|
||||
p.cover_uri = None;
|
||||
p.title = likes_title.into();
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut seen: HashSet<(String, String)> = HashSet::new();
|
||||
pins.retain(|p| seen.insert((p.kind.clone(), p.id.clone())));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
@ -3054,4 +3081,41 @@ mod tests {
|
|||
assert!(!is_newer_version("v0.0.9", "0.1.0"));
|
||||
assert!(!is_newer_version("", "0.1.0"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_normalize_pins_keeps_friends_favorites_playlist() {
|
||||
let mut pins = vec![
|
||||
PinnedItem {
|
||||
id: "likes".into(),
|
||||
kind: "likes".into(),
|
||||
title: "Мне нравится".into(),
|
||||
subtitle: "Плейлист".into(),
|
||||
cover_uri: None,
|
||||
owner_uid: Some("1001".into()),
|
||||
},
|
||||
PinnedItem {
|
||||
id: "1001:3".into(),
|
||||
kind: "playlist".into(),
|
||||
title: "Мне нравится".into(),
|
||||
subtitle: "Плейлист".into(),
|
||||
cover_uri: None,
|
||||
owner_uid: Some("1001".into()),
|
||||
},
|
||||
PinnedItem {
|
||||
id: "2002:3".into(),
|
||||
kind: "playlist".into(),
|
||||
title: "Мне нравится".into(),
|
||||
subtitle: "Плейлист".into(),
|
||||
cover_uri: None,
|
||||
owner_uid: Some("2002".into()),
|
||||
},
|
||||
];
|
||||
normalize_pins(&mut pins, Some(1001), true);
|
||||
assert_eq!(pins.len(), 2, "Own likes + friend's kind=3 likes must BOTH remain");
|
||||
assert_eq!(pins[0].kind, "likes");
|
||||
assert_eq!(pins[0].id, "likes");
|
||||
assert_eq!(pins[1].kind, "playlist");
|
||||
assert_eq!(pins[1].id, "2002:3");
|
||||
assert_eq!(pins[1].owner_uid.as_deref(), Some("2002"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue