more refactors and logs page handling
This commit is contained in:
@@ -13,7 +13,7 @@ class StoreRepository with LogMixin implements IStoreRepository {
|
||||
const StoreRepository({required DriftDatabaseRepository db}) : _db = db;
|
||||
|
||||
@override
|
||||
FutureOr<T?> tryGet<T, U>(StoreKey<T, U> key) async {
|
||||
Future<T?> tryGet<T, U>(StoreKey<T, U> key) async {
|
||||
final storeData = await _db.managers.store
|
||||
.filter((s) => s.id.equals(key.id))
|
||||
.getSingleOrNull();
|
||||
@@ -21,7 +21,7 @@ class StoreRepository with LogMixin implements IStoreRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOr<T> get<T, U>(StoreKey<T, U> key) async {
|
||||
Future<T> get<T, U>(StoreKey<T, U> key) async {
|
||||
final value = await tryGet(key);
|
||||
if (value == null) {
|
||||
throw StoreKeyNotFoundException(key);
|
||||
@@ -30,16 +30,16 @@ class StoreRepository with LogMixin implements IStoreRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOr<bool> upsert<T, U>(StoreKey<T, U> key, T value) async {
|
||||
Future<bool> upsert<T, U>(StoreKey<T, U> key, T value) async {
|
||||
try {
|
||||
final storeValue = key.converter.toPrimitive(value);
|
||||
final intValue = (key.type == int) ? storeValue as int : null;
|
||||
final stringValue = (key.type == String) ? storeValue as String : null;
|
||||
await _db.into(_db.store).insertOnConflictUpdate(StoreCompanion.insert(
|
||||
id: Value(key.id),
|
||||
intValue: Value(intValue),
|
||||
stringValue: Value(stringValue),
|
||||
));
|
||||
await _db.store.insertOnConflictUpdate(StoreCompanion.insert(
|
||||
id: Value(key.id),
|
||||
intValue: Value(intValue),
|
||||
stringValue: Value(stringValue),
|
||||
));
|
||||
return true;
|
||||
} catch (e, s) {
|
||||
log.e("Cannot set store value - ${key.name}; id - ${key.id}", e, s);
|
||||
@@ -48,7 +48,7 @@ class StoreRepository with LogMixin implements IStoreRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOr<void> delete(StoreKey key) async {
|
||||
Future<void> delete(StoreKey key) async {
|
||||
await _db.managers.store.filter((s) => s.id.equals(key.id)).delete();
|
||||
}
|
||||
|
||||
@@ -61,11 +61,11 @@ class StoreRepository with LogMixin implements IStoreRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOr<void> deleteAll() async {
|
||||
Future<void> deleteAll() async {
|
||||
await _db.managers.store.delete();
|
||||
}
|
||||
|
||||
FutureOr<T?> _getValueFromStoreData<T, U>(
|
||||
Future<T?> _getValueFromStoreData<T, U>(
|
||||
StoreKey<T, U> key,
|
||||
StoreData? data,
|
||||
) async {
|
||||
|
||||
Reference in New Issue
Block a user