refactoring
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:lensai/extensions/database_table_size.dart';
|
||||
import 'package:lensai/data/database/extensions/database_table_size.dart';
|
||||
import 'package:lensai/features/user/data/database/database.dart';
|
||||
|
||||
part 'cache.g.dart';
|
||||
@@ -8,7 +8,7 @@ part 'cache.g.dart';
|
||||
class CacheDao extends DatabaseAccessor<UserDatabase> with _$CacheDaoMixin {
|
||||
CacheDao(super.attachedDatabase);
|
||||
|
||||
SingleSelectable<double> iconCacheSize() {
|
||||
SingleSelectable<double> getIconCacheSize() {
|
||||
return db.tableSize(db.iconCache);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class SettingDao extends DatabaseAccessor<UserDatabase> with _$SettingDaoMixin {
|
||||
);
|
||||
}
|
||||
|
||||
Selectable<MapEntry<String, DriftAny?>> allSettingsOfPartitionKey(
|
||||
Selectable<MapEntry<String, DriftAny?>> getAllSettingsOfPartitionKey(
|
||||
String? partitionKey,
|
||||
) {
|
||||
final query =
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class AuthException implements Exception {
|
||||
final String message;
|
||||
|
||||
AuthException(this.message);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -9,18 +9,18 @@ part 'providers.g.dart';
|
||||
|
||||
const _authKey = 'pb_auth';
|
||||
|
||||
@Riverpod()
|
||||
Stream<double> iconCacheSizeMegabytes(Ref ref) {
|
||||
final repository = ref.watch(userDatabaseProvider);
|
||||
return repository.cacheDao.iconCacheSize().watchSingle();
|
||||
}
|
||||
|
||||
@Riverpod()
|
||||
Future<String?> _storedAuthData(Ref ref) {
|
||||
const secureStorage = FlutterSecureStorage();
|
||||
return secureStorage.read(key: _authKey);
|
||||
}
|
||||
|
||||
@Riverpod()
|
||||
Stream<double> iconCacheSizeMegabytes(Ref ref) {
|
||||
final repository = ref.watch(userDatabaseProvider);
|
||||
return repository.cacheDao.getIconCacheSize().watchSingle();
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
AsyncAuthStore authStore(Ref ref) {
|
||||
const secureStorage = FlutterSecureStorage();
|
||||
|
||||
@@ -6,25 +6,6 @@ part of 'providers.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$iconCacheSizeMegabytesHash() =>
|
||||
r'43162fce3ce8b04a5a55ed52021b274afbde2861';
|
||||
|
||||
/// See also [iconCacheSizeMegabytes].
|
||||
@ProviderFor(iconCacheSizeMegabytes)
|
||||
final iconCacheSizeMegabytesProvider =
|
||||
AutoDisposeStreamProvider<double>.internal(
|
||||
iconCacheSizeMegabytes,
|
||||
name: r'iconCacheSizeMegabytesProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$iconCacheSizeMegabytesHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
typedef IconCacheSizeMegabytesRef = AutoDisposeStreamProviderRef<double>;
|
||||
String _$storedAuthDataHash() => r'5f7e3ef6233a2036f7ce3728131901a46b1e548e';
|
||||
|
||||
/// See also [_storedAuthData].
|
||||
@@ -42,6 +23,25 @@ final _storedAuthDataProvider = AutoDisposeFutureProvider<String?>.internal(
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
typedef _StoredAuthDataRef = AutoDisposeFutureProviderRef<String?>;
|
||||
String _$iconCacheSizeMegabytesHash() =>
|
||||
r'5d7f5f6485060b08ce4fd8fa634f07bf8bfdbd2d';
|
||||
|
||||
/// See also [iconCacheSizeMegabytes].
|
||||
@ProviderFor(iconCacheSizeMegabytes)
|
||||
final iconCacheSizeMegabytesProvider =
|
||||
AutoDisposeStreamProvider<double>.internal(
|
||||
iconCacheSizeMegabytes,
|
||||
name: r'iconCacheSizeMegabytesProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$iconCacheSizeMegabytesHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
typedef IconCacheSizeMegabytesRef = AutoDisposeStreamProviderRef<double>;
|
||||
String _$authStoreHash() => r'766c001bbb8d7dc4e148eff3816c414d78e77f26';
|
||||
|
||||
/// See also [authStore].
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:lensai/features/user/domain/entities/auth_exception.dart';
|
||||
import 'package:lensai/features/user/domain/providers.dart';
|
||||
import 'package:lensai/features/user/extensions/client_exception.dart';
|
||||
import 'package:pocketbase/pocketbase.dart';
|
||||
@@ -5,17 +6,6 @@ import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'auth.g.dart';
|
||||
|
||||
class AuthException implements Exception {
|
||||
final String message;
|
||||
|
||||
AuthException(this.message);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
@Riverpod()
|
||||
class AuthRepository extends _$AuthRepository {
|
||||
late PocketBase _pb;
|
||||
|
||||
@@ -35,7 +35,7 @@ class EngineSettingsRepository extends _$EngineSettingsRepository {
|
||||
final db = ref.watch(userDatabaseProvider);
|
||||
|
||||
final watchSub = db.settingDao
|
||||
.allSettingsOfPartitionKey(_partitionKey)
|
||||
.getAllSettingsOfPartitionKey(_partitionKey)
|
||||
.watch()
|
||||
.listen((entries) {
|
||||
final settings = Map.fromEntries(entries);
|
||||
|
||||
@@ -7,7 +7,7 @@ part of 'engine_settings.dart';
|
||||
// **************************************************************************
|
||||
|
||||
String _$engineSettingsRepositoryHash() =>
|
||||
r'113617b3a99377bbb83347cfcb6d432abaae6f71';
|
||||
r'940680d6d59a4a4a496589ac02eeab5a22779e5e';
|
||||
|
||||
/// See also [EngineSettingsRepository].
|
||||
@ProviderFor(EngineSettingsRepository)
|
||||
|
||||
@@ -43,7 +43,7 @@ class GeneralSettingsRepository extends _$GeneralSettingsRepository {
|
||||
return ref
|
||||
.read(userDatabaseProvider)
|
||||
.settingDao
|
||||
.allSettingsOfPartitionKey(_partitionKey)
|
||||
.getAllSettingsOfPartitionKey(_partitionKey)
|
||||
.get()
|
||||
.then(_deserializeSettings);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class GeneralSettingsRepository extends _$GeneralSettingsRepository {
|
||||
final db = ref.watch(userDatabaseProvider);
|
||||
|
||||
final watchSub = db.settingDao
|
||||
.allSettingsOfPartitionKey(_partitionKey)
|
||||
.getAllSettingsOfPartitionKey(_partitionKey)
|
||||
.watch()
|
||||
.listen((event) {
|
||||
state = _deserializeSettings(event);
|
||||
|
||||
@@ -7,7 +7,7 @@ part of 'general_settings.dart';
|
||||
// **************************************************************************
|
||||
|
||||
String _$generalSettingsRepositoryHash() =>
|
||||
r'd21cee982ed471dff5ba11415e5557073bd2fca3';
|
||||
r'9753ffa757a34e475fe816ef990ca387ca169ef4';
|
||||
|
||||
/// See also [GeneralSettingsRepository].
|
||||
@ProviderFor(GeneralSettingsRepository)
|
||||
|
||||
Reference in New Issue
Block a user