v2.49.4 — Favoriten-Toggle race-sicher (kein PK-Crash bei Doppel-Tap)

## Fix (Code-Review Finding 2, HIGH)
- DbHelper.songZurPlaylist: INSERT OR IGNORE (ConflictAlgorithm.ignore) —
  Doppel-Tap-Race verletzt PRIMARY KEY (playlist_id, song_id) nicht mehr
- FavoritenService.umschalten: gibt neuen Status zurück, try/catch mit
  MeloLogger, Zustand nach Fehler aus DB neu geladen statt blind geflippt
- NowPlayingScreen._toggleFavorit: In-Flight-Guard _toggleLaeuft gegen
  parallele Toggles + Statusübernahme aus DB (Quelle der Wahrheit)
This commit is contained in:
Dustin
2026-08-04 16:46:49 +02:00
parent c6826db651
commit bd692d4682
3 changed files with 41 additions and 10 deletions
+3 -1
View File
@@ -401,11 +401,13 @@ class DbHelper {
Future<void> songZurPlaylist(int playlistId, int songId, int position) async {
final d = await db;
// INSERT OR IGNORE: Song bereits in der Playlist (Race/Doppel-Tap) ist
// kein Fehler — der Eintrag bleibt einfach bestehen (PK-Konflikt abgefangen).
await d.insert('playlist_songs', {
'playlist_id': playlistId,
'song_id': songId,
'position': position,
});
}, conflictAlgorithm: ConflictAlgorithm.ignore);
}
Future<List<Map<String, dynamic>>> allePlaylists() async {