mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-30 13:19:44 +02:00
feat(artists): add branded headers and incremental release loading
This commit is contained in:
1 parent
e61ff64adc
commit
dc25370350
11 files changed
+556
-145
No files matched your search
@@ -79,6 +79,8 @@ impl Backend {
|
||||
"image_url",
|
||||
"header_image",
|
||||
"header_video",
|
||||
"header_logo",
|
||||
"albums_next",
|
||||
"provider_id",
|
||||
],
|
||||
);
|
||||
@@ -422,7 +424,15 @@ fn response(kind: &str, value: &Value, check: &Check<'_>) -> Result<Value, Resol
|
||||
.unwrap_or_default();
|
||||
let mut info = strings(
|
||||
value,
|
||||
&["id", "name", "header_image", "header_video", "provider_id"],
|
||||
&[
|
||||
"id",
|
||||
"name",
|
||||
"header_image",
|
||||
"header_video",
|
||||
"header_logo",
|
||||
"albums_next",
|
||||
"provider_id",
|
||||
],
|
||||
);
|
||||
info.insert("images".into(), json!(image));
|
||||
info.insert("cover_url".into(), json!(cover));
|
||||
|
||||
@@ -17,7 +17,11 @@ function collection(id) {
|
||||
provider_id: "supplied-track", duration_ms: 123456, track_number: i + 1,
|
||||
explicit: i % 2 === 0, external_links: {example: "https://example.invalid/track/" + i}}))};
|
||||
}
|
||||
registerExtension({getAlbum: collection, getPlaylist: collection});
|
||||
function getArtist(id) {
|
||||
return {id, name: "Example Artist", image_url: "https://example.invalid/portrait.jpg",
|
||||
headerLogo: "https://example.invalid/logo.png", albumsNext: "artist-page-2", albums: []};
|
||||
}
|
||||
registerExtension({getAlbum: collection, getPlaylist: collection, getArtist});
|
||||
"#;
|
||||
|
||||
fn fixture() -> (tempfile::TempDir, Backend) {
|
||||
@@ -45,6 +49,26 @@ fn fixture() -> (tempfile::TempDir, Backend) {
|
||||
(root, backend)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn artist_metadata_preserves_logo_separately_from_portrait() {
|
||||
let (_root, backend) = fixture();
|
||||
let raw = backend
|
||||
.get_provider_metadata_json(ID, "artist", "artist-1", &|| Ok(()))
|
||||
.unwrap();
|
||||
let value: Value = serde_json::from_str(&raw).unwrap();
|
||||
assert_eq!(
|
||||
value["artist_info"]["header_logo"],
|
||||
"https://example.invalid/logo.png"
|
||||
);
|
||||
assert_eq!(
|
||||
value["artist_info"]["images"],
|
||||
"https://example.invalid/portrait.jpg"
|
||||
);
|
||||
assert_eq!(value["artist_info"]["name"], "Example Artist");
|
||||
assert_eq!(value["artist_info"]["albums_next"], "artist-page-2");
|
||||
backend.shutdown();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn metadata_value_bridge_preserves_album_playlist_and_public_json() {
|
||||
let (_root, backend) = fixture();
|
||||
|
||||
@@ -194,6 +194,8 @@
|
||||
const tracks = array(first(object(value), ["top_tracks","topTracks","tracks"]), track);
|
||||
const result = fields(value, [["id","s"],["name","s"],["image_url","s","imageUrl"],
|
||||
["header_image","s","headerImage"],["header_video","s","headerVideo"],
|
||||
["header_logo","s","headerLogo"],
|
||||
["albums_next","s","albumsNext"],
|
||||
["listeners","i"],["provider_id","s","providerId"]], ["id","name","provider_id"]);
|
||||
if (albums.length) result.albums = albums;
|
||||
if (releases.length) result.releases = releases;
|
||||
|
||||
Reference in new issue
Block a user