🌟 Feature: Favoriten-Sync vom Navidrome-Server (Phase 2, Part 4/X)
- syncFavoritesFromServer() in PlaylistService laden Server-Favoriten - Prüft lokal existierende Songs und markiert als Favorit - Settings-Button: "🌟 Favoriten-Sync" mit Cloud-Download Icon - Zeigt Anzahl importierter Favoriten mit SnackBar - DB-Methoden hinzugefügt: songExists() + setFavorite() Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XJzQjUtnvYUtHdnTs3iCru
This commit is contained in:
co-authored by
Claude Haiku 4.5
parent
49a8e91a63
commit
b37f7c7a2f
@@ -247,6 +247,23 @@ class MeloDb extends _$MeloDb {
|
||||
}
|
||||
|
||||
// === Favorites ===
|
||||
Future<bool> songExists(String songId) async {
|
||||
final row = await (select(songs)..where((s) => s.id.equals(songId))).getSingleOrNull();
|
||||
return row != null;
|
||||
}
|
||||
|
||||
Future<void> setFavorite(String songId, bool isFavorite) async {
|
||||
final existing = await (select(favorites)..where((f) => f.songId.equals(songId))).getSingleOrNull();
|
||||
if (isFavorite && existing == null) {
|
||||
await into(favorites).insert(FavoritesCompanion.insert(
|
||||
songId: songId,
|
||||
createdAtMs: DateTime.now().millisecondsSinceEpoch,
|
||||
));
|
||||
} else if (!isFavorite && existing != null) {
|
||||
await (delete(favorites)..where((f) => f.songId.equals(songId))).go();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> toggleFavorite(String songId) async {
|
||||
final existing = await (select(favorites)..where((f) => f.songId.equals(songId))).getSingleOrNull();
|
||||
if (existing == null) {
|
||||
|
||||
Reference in New Issue
Block a user