mirror of
https://github.com/immich-app/immich
synced 2025-06-08 20:09:21 +00:00
simplify local album repo method names
This commit is contained in:
parent
20d81d4a0f
commit
71b279ea04
@ -5,9 +5,9 @@ import 'package:immich_mobile/domain/models/local_album.model.dart';
|
|||||||
abstract interface class ILocalAlbumRepository implements IDatabaseRepository {
|
abstract interface class ILocalAlbumRepository implements IDatabaseRepository {
|
||||||
Future<List<LocalAlbum>> getAll({Set<SortLocalAlbumsBy> sortBy = const {}});
|
Future<List<LocalAlbum>> getAll({Set<SortLocalAlbumsBy> sortBy = const {}});
|
||||||
|
|
||||||
Future<List<LocalAsset>> getAssetsForAlbum(String albumId);
|
Future<List<LocalAsset>> getAssets(String albumId);
|
||||||
|
|
||||||
Future<List<String>> getAssetIdsForAlbum(String albumId);
|
Future<List<String>> getAssetIds(String albumId);
|
||||||
|
|
||||||
Future<void> upsert(
|
Future<void> upsert(
|
||||||
LocalAlbum album, {
|
LocalAlbum album, {
|
||||||
@ -25,10 +25,7 @@ abstract interface class ILocalAlbumRepository implements IDatabaseRepository {
|
|||||||
required Map<String, List<String>> assetAlbums,
|
required Map<String, List<String>> assetAlbums,
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<void> syncAlbumDeletes(
|
Future<void> syncDeletes(String albumId, Iterable<String> assetIdsToKeep);
|
||||||
String albumId,
|
|
||||||
Iterable<String> assetIdsToKeep,
|
|
||||||
);
|
|
||||||
|
|
||||||
Future<List<LocalAsset>> getAssetsToHash(String albumId);
|
Future<List<LocalAsset>> getAssetsToHash(String albumId);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ class LocalSyncService {
|
|||||||
if (_platform.isAndroid) {
|
if (_platform.isAndroid) {
|
||||||
for (final album in dbAlbums) {
|
for (final album in dbAlbums) {
|
||||||
final deviceIds = await _nativeSyncApi.getAssetIdsForAlbum(album.id);
|
final deviceIds = await _nativeSyncApi.getAssetIdsForAlbum(album.id);
|
||||||
await _localAlbumRepository.syncAlbumDeletes(album.id, deviceIds);
|
await _localAlbumRepository.syncDeletes(album.id, deviceIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ class LocalSyncService {
|
|||||||
.then((a) => a.toLocalAssets())
|
.then((a) => a.toLocalAssets())
|
||||||
: <LocalAsset>[];
|
: <LocalAsset>[];
|
||||||
final assetsInDb = dbAlbum.assetCount > 0
|
final assetsInDb = dbAlbum.assetCount > 0
|
||||||
? await _localAlbumRepository.getAssetsForAlbum(dbAlbum.id)
|
? await _localAlbumRepository.getAssets(dbAlbum.id)
|
||||||
: <LocalAsset>[];
|
: <LocalAsset>[];
|
||||||
|
|
||||||
if (deviceAlbum.assetCount == 0) {
|
if (deviceAlbum.assetCount == 0) {
|
||||||
|
@ -63,7 +63,7 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository
|
|||||||
// That is not the case on Android since asset <-> album has one:one mapping
|
// That is not the case on Android since asset <-> album has one:one mapping
|
||||||
final assetsToDelete = _platform.isIOS
|
final assetsToDelete = _platform.isIOS
|
||||||
? await _getUniqueAssetsInAlbum(albumId)
|
? await _getUniqueAssetsInAlbum(albumId)
|
||||||
: await getAssetIdsForAlbum(albumId);
|
: await getAssetIds(albumId);
|
||||||
await _deleteAssets(assetsToDelete);
|
await _deleteAssets(assetsToDelete);
|
||||||
|
|
||||||
// All the other assets that are still associated will be unlinked automatically on-cascade
|
// All the other assets that are still associated will be unlinked automatically on-cascade
|
||||||
@ -73,7 +73,7 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository
|
|||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> syncAlbumDeletes(
|
Future<void> syncDeletes(
|
||||||
String albumId,
|
String albumId,
|
||||||
Iterable<String> assetIdsToKeep,
|
Iterable<String> assetIdsToKeep,
|
||||||
) async {
|
) async {
|
||||||
@ -186,7 +186,7 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<LocalAsset>> getAssetsForAlbum(String albumId) {
|
Future<List<LocalAsset>> getAssets(String albumId) {
|
||||||
final query = _db.localAlbumAssetEntity.select().join(
|
final query = _db.localAlbumAssetEntity.select().join(
|
||||||
[
|
[
|
||||||
innerJoin(
|
innerJoin(
|
||||||
@ -203,7 +203,7 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<String>> getAssetIdsForAlbum(String albumId) {
|
Future<List<String>> getAssetIds(String albumId) {
|
||||||
final query = _db.localAlbumAssetEntity.selectOnly()
|
final query = _db.localAlbumAssetEntity.selectOnly()
|
||||||
..addColumns([_db.localAlbumAssetEntity.assetId])
|
..addColumns([_db.localAlbumAssetEntity.assetId])
|
||||||
..where(_db.localAlbumAssetEntity.albumId.equals(albumId));
|
..where(_db.localAlbumAssetEntity.albumId.equals(albumId));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user