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:
Alex
2025-02-18 13:10:55 -06:00
committed by GitHub
parent 70d08a2b2a
commit 9d4aee36e2
24 changed files with 326 additions and 299 deletions
@@ -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();
+13 -1
View File
@@ -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();
});
}
}