feat: full local assets / album sync
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:immich_mobile/domain/models/album.model.dart';
|
||||
|
||||
abstract interface class IAlbumRepository {
|
||||
/// Inserts a new album into the DB or updates if existing and returns the updated data
|
||||
FutureOr<Album?> upsert(Album album);
|
||||
|
||||
/// Fetch all albums
|
||||
FutureOr<List<Album>> getAll({bool localOnly, bool remoteOnly});
|
||||
|
||||
/// Removes album with the given [id]
|
||||
FutureOr<void> deleteId(int id);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:immich_mobile/domain/models/asset.model.dart';
|
||||
|
||||
abstract interface class IAlbumToAssetRepository {
|
||||
/// Link a list of assetIds to the given albumId
|
||||
FutureOr<bool> addAssetIds(int albumId, Iterable<int> assetIds);
|
||||
|
||||
/// Returns assets that are only part of the given album and nothing else
|
||||
FutureOr<List<int>> getAssetIdsOnlyInAlbum(int albumId);
|
||||
|
||||
/// Returns the assets for the given [albumId]
|
||||
FutureOr<List<Asset>> getAssetsForAlbum(int albumId);
|
||||
|
||||
/// Removes album with the given [albumId]
|
||||
FutureOr<void> deleteAlbumId(int albumId);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:immich_mobile/domain/models/album_etag.model.dart';
|
||||
|
||||
abstract interface class IAlbumETagRepository {
|
||||
/// Inserts or updates the album etag for the given [albumId]
|
||||
FutureOr<bool> upsert(AlbumETag albumETag);
|
||||
|
||||
/// Fetches the album etag for the given [albumId]
|
||||
FutureOr<AlbumETag?> get(int albumId);
|
||||
}
|
||||
@@ -7,16 +7,19 @@ abstract interface class IAssetRepository {
|
||||
FutureOr<bool> upsertAll(Iterable<Asset> assets);
|
||||
|
||||
/// Removes assets with the [localIds]
|
||||
FutureOr<List<Asset>> getForLocalIds(List<String> localIds);
|
||||
FutureOr<List<Asset>> getForLocalIds(Iterable<String> localIds);
|
||||
|
||||
/// Removes assets with the [remoteIds]
|
||||
FutureOr<List<Asset>> getForRemoteIds(List<String> remoteIds);
|
||||
FutureOr<List<Asset>> getForRemoteIds(Iterable<String> remoteIds);
|
||||
|
||||
/// Get assets with the [hashes]
|
||||
FutureOr<List<Asset>> getForHashes(Iterable<String> hashes);
|
||||
|
||||
/// Fetch assets from the [offset] with the [limit]
|
||||
FutureOr<List<Asset>> getAll({int? offset, int? limit});
|
||||
|
||||
/// Removes assets with the given [ids]
|
||||
FutureOr<void> deleteIds(List<int> ids);
|
||||
FutureOr<void> deleteIds(Iterable<int> ids);
|
||||
|
||||
/// Removes all assets
|
||||
FutureOr<bool> deleteAll();
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
abstract interface class IDatabaseRepository {
|
||||
/// Runs the [action] in a transaction
|
||||
Future<T> txn<T>(Future<T> Function() action);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:immich_mobile/domain/models/album.model.dart';
|
||||
import 'package:immich_mobile/domain/models/asset.model.dart';
|
||||
|
||||
abstract interface class IDeviceAlbumRepository {
|
||||
/// Fetches all [Album] from device
|
||||
FutureOr<List<Album>> getAll();
|
||||
|
||||
/// Returns the number of asset in the album
|
||||
FutureOr<int> getAssetCount(String albumId);
|
||||
|
||||
/// Fetches assets belong to the albumId
|
||||
FutureOr<List<Asset>> getAssetsForAlbum(
|
||||
String albumId, {
|
||||
int start = 0,
|
||||
int end = 0x7fffffffffffffff,
|
||||
DateTime? modifiedFrom,
|
||||
DateTime? modifiedUntil,
|
||||
bool orderByModificationDate = false,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:immich_mobile/domain/models/asset.model.dart';
|
||||
import 'package:immich_mobile/domain/models/device_asset_download.model.dart';
|
||||
import 'package:immich_mobile/utils/constants/globals.dart';
|
||||
|
||||
abstract interface class IDeviceAssetRepository<T> {
|
||||
/// Fetches the [File] for the given [assetId]
|
||||
FutureOr<File?> getOriginalFile(String assetId);
|
||||
|
||||
/// Fetches the thumbnail for the given [assetId]
|
||||
FutureOr<Uint8List?> getThumbnail(
|
||||
String assetId, {
|
||||
int width = kGridThumbnailSize,
|
||||
int height = kGridThumbnailSize,
|
||||
int quality = kGridThumbnailQuality,
|
||||
DeviceAssetDownloadHandler? downloadHandler,
|
||||
});
|
||||
|
||||
/// Converts the given [entity] to an [Asset]
|
||||
Future<Asset> toAsset(T entity);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:immich_mobile/domain/models/device_asset_hash.model.dart';
|
||||
|
||||
abstract interface class IDeviceAssetToHashRepository {
|
||||
/// Add a new device asset to hash entry
|
||||
FutureOr<bool> upsertAll(Iterable<DeviceAssetToHash> assetHash);
|
||||
|
||||
// Gets the asset with the local ID from the device
|
||||
FutureOr<List<DeviceAssetToHash>> getForIds(Iterable<String> localIds);
|
||||
|
||||
/// Removes assets with the given [ids]
|
||||
FutureOr<void> deleteIds(Iterable<int> ids);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ abstract interface class ILogRepository {
|
||||
FutureOr<bool> create(LogMessage log);
|
||||
|
||||
/// Bulk insert logs into DB
|
||||
FutureOr<bool> createAll(List<LogMessage> log);
|
||||
FutureOr<bool> createAll(Iterable<LogMessage> log);
|
||||
|
||||
/// Fetches all logs
|
||||
FutureOr<List<LogMessage>> getAll();
|
||||
|
||||
Reference in New Issue
Block a user