mirror of
https://github.com/immich-app/immich.git
synced 2025-12-26 09:14:58 +03:00
feat(mobile): remote album sync (#18876)
* feat(mobile): remote album sync * fix: lint * missing createdAt field * lint
This commit is contained in:
@@ -15,4 +15,13 @@ abstract interface class ISyncStreamRepository implements IDatabaseRepository {
|
||||
Future<void> updatePartnerAssetsV1(Iterable<SyncAssetV1> data);
|
||||
Future<void> deletePartnerAssetsV1(Iterable<SyncAssetDeleteV1> data);
|
||||
Future<void> updatePartnerAssetsExifV1(Iterable<SyncAssetExifV1> data);
|
||||
|
||||
Future<void> updateAlbumsV1(Iterable<SyncAlbumV1> data);
|
||||
Future<void> deleteAlbumsV1(Iterable<SyncAlbumDeleteV1> data);
|
||||
|
||||
// Future<void> updateAlbumAssetsV1(Iterable<SyncAlbumAssetV1> data);
|
||||
// Future<void> deleteAlbumAssetsV1(Iterable<SyncAlbumAssetV1> data);
|
||||
|
||||
Future<void> updateAlbumUsersV1(Iterable<SyncAlbumUserV1> data);
|
||||
Future<void> deleteAlbumUsersV1(Iterable<SyncAlbumUserDeleteV1> data);
|
||||
}
|
||||
|
||||
68
mobile/lib/domain/models/album/album.model.dart
Normal file
68
mobile/lib/domain/models/album/album.model.dart
Normal file
@@ -0,0 +1,68 @@
|
||||
enum AssetOrder {
|
||||
// do not change this order!
|
||||
asc,
|
||||
desc,
|
||||
}
|
||||
|
||||
// Model for an album stored in the server
|
||||
class Album {
|
||||
final String id;
|
||||
final String name;
|
||||
final String description;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final String? thumbnailAssetId;
|
||||
final bool isActivityEnabled;
|
||||
final AssetOrder order;
|
||||
|
||||
const Album({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.description,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
this.thumbnailAssetId,
|
||||
required this.isActivityEnabled,
|
||||
required this.order,
|
||||
});
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '''Album {
|
||||
id: $id,
|
||||
name: $name,
|
||||
description: $description,
|
||||
createdAt: $createdAt,
|
||||
updatedAt: $updatedAt,
|
||||
isActivityEnabled: $isActivityEnabled,
|
||||
order: $order,
|
||||
thumbnailAssetId: ${thumbnailAssetId ?? "<NA>"}
|
||||
}''';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (other is! Album) return false;
|
||||
if (identical(this, other)) return true;
|
||||
return id == other.id &&
|
||||
name == other.name &&
|
||||
description == other.description &&
|
||||
createdAt == other.createdAt &&
|
||||
updatedAt == other.updatedAt &&
|
||||
thumbnailAssetId == other.thumbnailAssetId &&
|
||||
isActivityEnabled == other.isActivityEnabled &&
|
||||
order == other.order;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return id.hashCode ^
|
||||
name.hashCode ^
|
||||
description.hashCode ^
|
||||
createdAt.hashCode ^
|
||||
updatedAt.hashCode ^
|
||||
thumbnailAssetId.hashCode ^
|
||||
isActivityEnabled.hashCode ^
|
||||
order.hashCode;
|
||||
}
|
||||
}
|
||||
5
mobile/lib/domain/models/album_user.model.dart
Normal file
5
mobile/lib/domain/models/album_user.model.dart
Normal file
@@ -0,0 +1,5 @@
|
||||
enum AlbumUserRole {
|
||||
// do not change this order!
|
||||
editor,
|
||||
viewer,
|
||||
}
|
||||
@@ -81,6 +81,18 @@ class SyncStreamService {
|
||||
return _syncStreamRepository.deletePartnerAssetsV1(data.cast());
|
||||
case SyncEntityType.partnerAssetExifV1:
|
||||
return _syncStreamRepository.updatePartnerAssetsExifV1(data.cast());
|
||||
case SyncEntityType.albumV1:
|
||||
return _syncStreamRepository.updateAlbumsV1(data.cast());
|
||||
case SyncEntityType.albumDeleteV1:
|
||||
return _syncStreamRepository.deleteAlbumsV1(data.cast());
|
||||
// case SyncEntityType.albumAssetV1:
|
||||
// return _syncStreamRepository.updateAlbumAssetsV1(data.cast());
|
||||
// case SyncEntityType.albumAssetDeleteV1:
|
||||
// return _syncStreamRepository.deleteAlbumAssetsV1(data.cast());
|
||||
case SyncEntityType.albumUserV1:
|
||||
return _syncStreamRepository.updateAlbumUsersV1(data.cast());
|
||||
case SyncEntityType.albumUserDeleteV1:
|
||||
return _syncStreamRepository.deleteAlbumUsersV1(data.cast());
|
||||
default:
|
||||
_logger.warning("Unknown sync data type: $type");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user