Files
bvandeusen c0785cf894 feat(flutter/models): User, ArtistRef, AlbumRef, TrackRef, HomeData
Field names mirror web/src/lib/api/types.ts and the server JSON shape
(internal/api/types.go's HomePayload). Hand-written DTOs per spec
section 10 -- codegen revisits at ~30 models.

Adopts server contract over plan-body mock:
- cover_url (not cover_art_url) for artist/album refs
- duration_sec (not duration_ms) for albums and tracks
- stream_url, disc_number on TrackRef
- sort_name/album_count on ArtistRef; sort_title/year/track_count on AlbumRef

HomeData section keys match server: recently_added_albums,
rediscover_albums, rediscover_artists, most_played_tracks,
last_played_artists.
2026-05-02 17:18:12 -04:00

31 lines
1003 B
Dart

// Mirrors internal/api/types.go ArtistRef and web/src/lib/api/types.ts.
//
// `cover_url` is the server's field name (NOT cover_art_url). Server emits
// "" when the artist has no representative album cover, so we keep it
// non-null here and let UI code branch on isEmpty. `sort_name` and
// `album_count` are exposed by the server contract; we accept their
// absence defensively (older fixtures, partial mocks).
class ArtistRef {
const ArtistRef({
required this.id,
required this.name,
this.sortName = '',
this.albumCount = 0,
this.coverUrl = '',
});
final String id;
final String name;
final String sortName;
final int albumCount;
final String coverUrl;
factory ArtistRef.fromJson(Map<String, dynamic> j) => ArtistRef(
id: j['id'] as String,
name: j['name'] as String,
sortName: j['sort_name'] as String? ?? '',
albumCount: (j['album_count'] as num?)?.toInt() ?? 0,
coverUrl: j['cover_url'] as String? ?? '',
);
}