fix(flutter): tighter track row + missing artist in mini player + hide redundant artist on artist page
Track row (album detail): - Vertical padding 10→6 and only render the artist line when non-empty, so tracks without a populated artist row don't reserve a blank line. - Number column 28→22 — visually tighter without making 3-digit numbers cramp. Mini player missing artist: - Symptom was an empty `artist` field on MediaItem after tapping a track in album detail; layout change wasn't the cause. Real cause: albumProvider's cold-cache only wrote cachedAlbums + cachedTracks, never cachedArtists. The drift JOINs that build the AlbumRef + each TrackRef returned null for the artist row, so artistName fell back to '' and the audio handler stamped MediaItem.artist=''. - Cold-cache now collects every distinct (artistId, artistName) pair off the album header + each track, inserts them into cachedArtists alongside the album/tracks. Subsequent JOINs populate artistName, the audio handler stamps it on MediaItem, and the mini player picks it up via the existing artistName.isNotEmpty render. - Existing cached albums won't get artist names until they're re-fetched (cache invalidation TBD). Future cold-cache hits will. Artist detail album grid: - AlbumCard gains showArtist (default true). Pass false in the artist detail grid since the page header already names the artist. cellH trimmed by the 16dp artist line.
This commit is contained in:
@@ -179,7 +179,35 @@ final albumProvider = StreamProvider.family<
|
||||
.getAlbum(albumId)
|
||||
.timeout(const Duration(seconds: 10));
|
||||
debugPrint('albumProvider($albumId): got ${fresh.tracks.length} tracks, writing to drift');
|
||||
// Collect every artist mentioned by the album + its tracks so
|
||||
// the JOINs that drive both the album header and the track
|
||||
// rows have something to bind to. Without this, drift returns
|
||||
// null for the artist row and artistName surfaces empty —
|
||||
// visible as a missing artist line in the mini player and
|
||||
// the row list.
|
||||
final artists = <String, ArtistRef>{};
|
||||
if (fresh.album.artistId.isNotEmpty &&
|
||||
fresh.album.artistName.isNotEmpty) {
|
||||
artists[fresh.album.artistId] = ArtistRef(
|
||||
id: fresh.album.artistId,
|
||||
name: fresh.album.artistName,
|
||||
);
|
||||
}
|
||||
for (final t in fresh.tracks) {
|
||||
if (t.artistId.isNotEmpty &&
|
||||
t.artistName.isNotEmpty &&
|
||||
!artists.containsKey(t.artistId)) {
|
||||
artists[t.artistId] = ArtistRef(
|
||||
id: t.artistId,
|
||||
name: t.artistName,
|
||||
);
|
||||
}
|
||||
}
|
||||
await db.batch((b) {
|
||||
if (artists.isNotEmpty) {
|
||||
b.insertAllOnConflictUpdate(
|
||||
db.cachedArtists, artists.values.map((a) => a.toDrift()).toList());
|
||||
}
|
||||
b.insertAllOnConflictUpdate(db.cachedAlbums, [fresh.album.toDrift()]);
|
||||
b.insertAllOnConflictUpdate(db.cachedTracks,
|
||||
fresh.tracks.map((t) => t.toDrift()).toList());
|
||||
|
||||
Reference in New Issue
Block a user