mirror of
https://github.com/austinried/subtracks.git
synced 2026-03-28 15:22:44 +01:00
active source switching and reactivity
This commit is contained in:
@@ -11,8 +11,8 @@ final databaseInitializer = FutureProvider<SubtracksDatabase>((ref) async {
|
||||
.insertOnConflictUpdate(
|
||||
SourcesCompanion.insert(
|
||||
id: Value(1),
|
||||
name: 'test navidrome',
|
||||
isActive: Value(true),
|
||||
name: 'test subsonic',
|
||||
// isActive: Value(true),
|
||||
),
|
||||
);
|
||||
await db
|
||||
@@ -23,9 +23,26 @@ final databaseInitializer = FutureProvider<SubtracksDatabase>((ref) async {
|
||||
address: Uri.parse('http://demo.subsonic.org'),
|
||||
username: 'guest1',
|
||||
password: 'guest',
|
||||
// address: Uri.parse('http://10.0.2.2:4533'),
|
||||
// username: 'admin',
|
||||
// password: 'password',
|
||||
useTokenAuth: Value(true),
|
||||
),
|
||||
);
|
||||
await db
|
||||
.into(db.sources)
|
||||
.insertOnConflictUpdate(
|
||||
SourcesCompanion.insert(
|
||||
id: Value(2),
|
||||
name: 'test navidrome',
|
||||
// isActive: Value(null),
|
||||
),
|
||||
);
|
||||
await db
|
||||
.into(db.subsonicSettings)
|
||||
.insertOnConflictUpdate(
|
||||
SubsonicSettingsCompanion.insert(
|
||||
sourceId: Value(2),
|
||||
address: Uri.parse('http://10.0.2.2:4533'),
|
||||
username: 'admin',
|
||||
password: 'password',
|
||||
useTokenAuth: Value(true),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user