refactor(mobile): encapsulate most access to photomanager in repository (#12754)

* refactor(mobile): encapsulate most access to photomanager in repository
This commit is contained in:
Fynn Petersen-Frey 2024-09-18 17:15:52 +02:00 committed by GitHub
parent 6740c67ed8
commit 6995cc2b38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 1205 additions and 500 deletions

View file

@ -1,45 +1,47 @@
import 'dart:typed_data';
import 'package:photo_manager/photo_manager.dart';
import 'package:immich_mobile/entities/album.entity.dart';
class AvailableAlbum {
final AssetPathEntity albumEntity;
final Album album;
final int assetCount;
final DateTime? lastBackup;
AvailableAlbum({
required this.albumEntity,
required this.album,
required this.assetCount,
this.lastBackup,
});
AvailableAlbum copyWith({
AssetPathEntity? albumEntity,
Album? album,
int? assetCount,
DateTime? lastBackup,
Uint8List? thumbnailData,
}) {
return AvailableAlbum(
albumEntity: albumEntity ?? this.albumEntity,
album: album ?? this.album,
assetCount: assetCount ?? this.assetCount,
lastBackup: lastBackup ?? this.lastBackup,
);
}
String get name => albumEntity.name;
String get name => album.name;
Future<int> get assetCount => albumEntity.assetCountAsync;
String get id => album.localId!;
String get id => albumEntity.id;
bool get isAll => albumEntity.isAll;
bool get isAll => album.isAll;
@override
String toString() =>
'AvailableAlbum(albumEntity: $albumEntity, lastBackup: $lastBackup)';
'AvailableAlbum(albumEntity: $album, lastBackup: $lastBackup)';
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is AvailableAlbum && other.albumEntity == albumEntity;
return other is AvailableAlbum && other.album == album;
}
@override
int get hashCode => albumEntity.hashCode;
int get hashCode => album.hashCode;
}

View file

@ -1,9 +1,9 @@
import 'package:photo_manager/photo_manager.dart';
import 'package:immich_mobile/entities/asset.entity.dart';
class BackupCandidate {
BackupCandidate({required this.asset, required this.albumNames});
AssetEntity asset;
Asset asset;
List<String> albumNames;
@override

View file

@ -1,11 +1,11 @@
import 'package:photo_manager/photo_manager.dart';
import 'package:immich_mobile/entities/asset.entity.dart';
class ErrorUploadAsset {
final String id;
final DateTime fileCreatedAt;
final String fileName;
final String fileType;
final AssetEntity asset;
final Asset asset;
final String errorMessage;
const ErrorUploadAsset({
@ -22,7 +22,7 @@ class ErrorUploadAsset {
DateTime? fileCreatedAt,
String? fileName,
String? fileType,
AssetEntity? asset,
Asset? asset,
String? errorMessage,
}) {
return ErrorUploadAsset(