active source switching and reactivity

This commit is contained in:
austinried
2025-11-22 11:33:40 +09:00
parent de9bc98044
commit 798a907cca
12 changed files with 271 additions and 774 deletions

View File

@@ -10,17 +10,17 @@ final activeSourceInitializer = StreamProvider<(int, SubsonicSource)>((
) async* {
final db = ref.watch(databaseProvider);
final activeSource = db.managers.sources
.filter((f) => f.isActive.equals(true))
.watchSingle();
final activeSource = db.sourcesDao.activeSourceId().watchSingle();
await for (final source in activeSource) {
final sourceId = source.read(db.sources.id)!;
final subsonicSettings = await db.managers.subsonicSettings
.filter((f) => f.sourceId.equals(source.id))
.filter((f) => f.sourceId.equals(sourceId))
.getSingle();
yield (
source.id,
sourceId,
SubsonicSource(
SubsonicClient(
http: SubtracksHttpClient(),