fix: Login-Fehlerhandler — 200 ohne Token abfangen, Server-Nachrichten parsen

This commit is contained in:
Dustin
2026-08-01 17:44:05 +02:00
parent 7f17a5afd6
commit a495a183d8
6 changed files with 122 additions and 7 deletions
+26 -2
View File
@@ -20,7 +20,7 @@ class DbHelper {
final pfad = await getDatabasesPath();
return openDatabase(
p.join(pfad, 'melo.db'),
version: 3,
version: 4,
onCreate: (db, version) async {
await db.execute('''
CREATE TABLE songs (
@@ -37,6 +37,7 @@ class DbHelper {
hinzugefuegt_am TEXT NOT NULL,
download_quelle TEXT DEFAULT 'local',
stream_url TEXT,
yt_url TEXT,
zuletzt_position INTEGER
)
''');
@@ -99,7 +100,13 @@ class DbHelper {
// Spalte existiert bereits ignorieren
}
}
// Weitere Migrationen: if (oldVersion < 4) { ... }
if (oldVersion < 4) {
try {
await db.execute('ALTER TABLE songs ADD COLUMN yt_url TEXT');
} catch (_) {
// Spalte existiert bereits ignorieren
}
}
},
);
}
@@ -205,6 +212,23 @@ class DbHelper {
return rows.map((r) => Song.fromMap(r)).toList();
}
/// YouTube-Quell-URL für einen Song speichern
Future<void> ytUrlAktualisieren(int songId, String ytUrl) async {
final d = await db;
await d.update('songs', {'yt_url': ytUrl},
where: 'id = ?', whereArgs: [songId]);
}
/// Alle Songs ohne YouTube-Quell-URL abrufen (für Scanner-Suche)
Future<List<Song>> songsOhneYtUrl({int limit = 50}) async {
final d = await db;
final rows = await d.query('songs',
where: 'yt_url IS NULL OR yt_url = ""',
orderBy: 'hinzugefuegt_am DESC',
limit: limit);
return rows.map((r) => Song.fromMap(r)).toList();
}
// ─── Tags ────────────────────────────────────────
Future<int> tagErstellen(String name, {String? icon, String? farbe}) async {