mirror of
https://github.com/austinried/subtracks.git
synced 2026-02-10 15:02:42 +01:00
migrate l10n, state preloading
This commit is contained in:
@@ -1,7 +1,37 @@
|
||||
import 'package:drift/drift.dart' show Value;
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
import '../../database/database.dart';
|
||||
|
||||
final databaseProvider = Provider<SubtracksDatabase>((ref) {
|
||||
return SubtracksDatabase();
|
||||
final databaseInitializer = FutureProvider<SubtracksDatabase>((ref) async {
|
||||
final db = SubtracksDatabase();
|
||||
|
||||
await db
|
||||
.into(db.sources)
|
||||
.insertOnConflictUpdate(
|
||||
SourcesCompanion.insert(
|
||||
id: Value(1),
|
||||
name: 'test navidrome',
|
||||
),
|
||||
);
|
||||
await db
|
||||
.into(db.subsonicSettings)
|
||||
.insertOnConflictUpdate(
|
||||
SubsonicSettingsCompanion.insert(
|
||||
sourceId: Value(1),
|
||||
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),
|
||||
),
|
||||
);
|
||||
|
||||
return db;
|
||||
});
|
||||
|
||||
final databaseProvider = Provider<SubtracksDatabase>((ref) {
|
||||
return ref.watch(databaseInitializer).requireValue;
|
||||
});
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
final sourceIdProvider = Provider<int>((ref) {
|
||||
return 1;
|
||||
});
|
||||
|
||||
final packageInfoInitializer = FutureProvider<PackageInfo>((ref) {
|
||||
return PackageInfo.fromPlatform();
|
||||
});
|
||||
|
||||
final packageInfoProvider = Provider<PackageInfo>((ref) {
|
||||
return ref.watch(packageInfoInitializer).requireValue;
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ import '../../util/http.dart';
|
||||
import 'database.dart';
|
||||
import 'settings.dart';
|
||||
|
||||
final _sourceProvider = FutureProvider<MusicSource>((ref) async {
|
||||
final sourceInitializer = FutureProvider<MusicSource>((ref) async {
|
||||
final db = ref.watch(databaseProvider);
|
||||
final sourceId = ref.watch(sourceIdProvider);
|
||||
|
||||
@@ -34,6 +34,5 @@ final _sourceProvider = FutureProvider<MusicSource>((ref) async {
|
||||
});
|
||||
|
||||
final sourceProvider = Provider<MusicSource>((ref) {
|
||||
final source = ref.watch(_sourceProvider);
|
||||
return source.requireValue;
|
||||
return ref.watch(sourceInitializer).value!;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user