refactor(mobile): asset provider (#16159)
* refactor(mobile): asset provider * wip * wip: delete local assets * wip: delete remote assets * wip: deletion logic * refactor * pr feedback
This commit is contained in:
@@ -155,6 +155,13 @@ class AlbumRepository extends DatabaseRepository implements IAlbumRepository {
|
||||
return await query.findAll();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> clearTable() async {
|
||||
await txn(() async {
|
||||
await db.albums.clear();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<List<Album>> watchRemoteAlbums() {
|
||||
return db.albums.where().remoteIdIsNotNull().watch();
|
||||
|
||||
@@ -57,7 +57,7 @@ class AssetRepository extends DatabaseRepository implements IAssetRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteById(List<int> ids) => txn(() async {
|
||||
Future<void> deleteByIds(List<int> ids) => txn(() async {
|
||||
await db.assets.deleteAll(ids);
|
||||
await db.exifInfos.deleteAll(ids);
|
||||
});
|
||||
@@ -210,6 +210,18 @@ class AssetRepository extends DatabaseRepository implements IAssetRepository {
|
||||
.thenByFileCreatedAtDesc()
|
||||
.findAll();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> clearTable() async {
|
||||
await txn(() async {
|
||||
await db.assets.clear();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<Asset?> watchAsset(int id, {bool fireImmediately = false}) {
|
||||
return db.assets.watchObject(id, fireImmediately: fireImmediately);
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<Asset>> _getMatchesImpl(
|
||||
|
||||
@@ -26,4 +26,11 @@ class ETagRepository extends DatabaseRepository implements IETagRepository {
|
||||
|
||||
@override
|
||||
Future<ETag?> getById(String id) => db.eTags.getById(id);
|
||||
|
||||
@override
|
||||
Future<void> clearTable() async {
|
||||
await txn(() async {
|
||||
await db.eTags.clear();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,4 +28,9 @@ class ExifInfoRepository extends DatabaseRepository
|
||||
await txn(() => db.exifInfos.putAll(exifInfos));
|
||||
return exifInfos;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> clearTable() {
|
||||
return txn(() => db.exifInfos.clear());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,4 +57,11 @@ class UserRepository extends DatabaseRepository implements IUserRepository {
|
||||
.or()
|
||||
.isarIdEqualTo(Store.get(StoreKey.currentUser).isarId)
|
||||
.findAll();
|
||||
|
||||
@override
|
||||
Future<void> clearTable() async {
|
||||
await txn(() async {
|
||||
await db.users.clear();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user