🌟 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
@@ -3,6 +3,7 @@ import 'package:provider/provider.dart';
|
||||
|
||||
import '../library/database.dart';
|
||||
import '../library/permissions.dart';
|
||||
import '../library/playlist_service.dart';
|
||||
import '../services/cache_manager.dart';
|
||||
import '../services/navidrome_service.dart';
|
||||
import '../services/offline_mode.dart';
|
||||
@@ -103,6 +104,16 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
)
|
||||
: null,
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.favorite),
|
||||
title: const Text('🌟 Favoriten-Sync'),
|
||||
subtitle: const Text('Favoriten vom Server importieren'),
|
||||
trailing: IconButton(
|
||||
tooltip: 'Vom Server laden',
|
||||
icon: const Icon(Icons.cloud_download),
|
||||
onPressed: () => _syncServerFavorites(),
|
||||
),
|
||||
),
|
||||
const Divider(height: 1),
|
||||
const _SectionLabel('Berechtigungen'),
|
||||
ListTile(
|
||||
@@ -242,6 +253,28 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _syncServerFavorites() async {
|
||||
final playlistService = context.read<PlaylistService>();
|
||||
if (!mounted) return;
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Lade Favoriten vom Server...')),
|
||||
);
|
||||
|
||||
final count = await playlistService.syncFavoritesFromServer();
|
||||
if (mounted) {
|
||||
if (count == 0) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('❌ Server nicht verbunden oder keine Favoriten')),
|
||||
);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('✅ $count Favoriten importiert')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String _formatBytes(int bytes) {
|
||||
if (bytes < 1024) return '$bytes B';
|
||||
if (bytes < 1024 * 1024) return '${(bytes / 1024).toStringAsFixed(1)} KB';
|
||||
|
||||
Reference in New Issue
Block a user