Zuletzt zeigt zuletzt Gehörtes statt neu Hinzugefügtes; Herz sitzt jetzt neben dem Songnamen
- MeloDb.watchRecentlyPlayed(): wertet PlaybackHistory statt dateAddedMs aus, ein mehrfach gehörter Song erscheint nur einmal, an der Position seines jüngsten Abspielens (Subquery mit GROUP BY songId / MAX(playedAtMs)). - "Zuletzt" (Karte + RecentlyPlayedScreen, vormals RecentlyAddedScreen) in my_music_screen.dart nutzt jetzt watchRecentlyPlayed() statt watchRecent(). - Herz im Vollbild-Player: aus der AppBar-actions-Row entfernt, sitzt jetzt direkt neben dem Songtitel in _Angaben (now_playing_screen.dart). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012A2pmbnVNPiHdyf2GW8eLP
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
90b63c467e
commit
2cabe36a6c
@@ -212,6 +212,35 @@ class MeloDb extends _$MeloDb {
|
||||
.watch();
|
||||
}
|
||||
|
||||
/// Überwacht die zuletzt GEHÖRTEN Songs (nicht getombstonte), aus
|
||||
/// [PlaybackHistory]. Ein mehrfach gespielter Song erscheint nur einmal —
|
||||
/// an der Position seines jüngsten Abspielens. Dafür wird pro [songId]
|
||||
/// zuerst der jüngste `playedAtMs`-Eintrag ermittelt (Subquery mit
|
||||
/// `GROUP BY`), und darüber zurück auf [songs] verknüpft.
|
||||
Stream<List<Song>> watchRecentlyPlayed({int limit = 50}) {
|
||||
final letzterPlay = playbackHistory.playedAtMs.max();
|
||||
final letztePlaysProSong = selectOnly(playbackHistory)
|
||||
..addColumns([playbackHistory.songId, letzterPlay])
|
||||
..groupBy([playbackHistory.songId]);
|
||||
final subquery = Subquery(letztePlaysProSong, 'letzte_plays');
|
||||
final letzterPlayRef = subquery.ref(letzterPlay);
|
||||
|
||||
final query = select(songs).join([
|
||||
innerJoin(
|
||||
subquery,
|
||||
subquery.ref(playbackHistory.songId).equalsExp(songs.id),
|
||||
useColumns: false,
|
||||
),
|
||||
])
|
||||
..where(songs.deleted.equals(false))
|
||||
..orderBy([
|
||||
OrderingTerm(expression: letzterPlayRef, mode: OrderingMode.desc)
|
||||
])
|
||||
..limit(limit);
|
||||
|
||||
return query.watch().map((rows) => rows.map((r) => r.readTable(songs)).toList());
|
||||
}
|
||||
|
||||
|
||||
/// Alle Songs inkl. getombstonte. Intern für ID-Stabilität beim Scan.
|
||||
Future<List<Song>> allSongs() => select(songs).get();
|
||||
|
||||
Reference in New Issue
Block a user