2022-06-18 14:36:58 +02:00
|
|
|
import 'package:cancellation_token_http/http.dart';
|
2022-05-06 14:22:23 +02:00
|
|
|
import 'package:equatable/equatable.dart';
|
|
|
|
import 'package:photo_manager/photo_manager.dart';
|
|
|
|
|
|
|
|
import 'package:immich_mobile/modules/backup/models/available_album.model.dart';
|
|
|
|
import 'package:immich_mobile/shared/models/server_info.model.dart';
|
|
|
|
|
|
|
|
enum BackUpProgressEnum { idle, inProgress, done }
|
|
|
|
|
|
|
|
class BackUpState extends Equatable {
|
|
|
|
// enum
|
|
|
|
final BackUpProgressEnum backupProgress;
|
2022-06-25 22:12:47 +02:00
|
|
|
final List<String> allAssetsInDatabase;
|
2022-05-06 14:22:23 +02:00
|
|
|
final double progressInPercentage;
|
2022-06-18 14:36:58 +02:00
|
|
|
final CancellationToken cancelToken;
|
2022-05-06 14:22:23 +02:00
|
|
|
final ServerInfo serverInfo;
|
|
|
|
|
|
|
|
/// All available albums on the device
|
|
|
|
final List<AvailableAlbum> availableAlbums;
|
|
|
|
final Set<AssetPathEntity> selectedBackupAlbums;
|
|
|
|
final Set<AssetPathEntity> excludedBackupAlbums;
|
|
|
|
|
|
|
|
/// Assets that are not overlapping in selected backup albums and excluded backup albums
|
|
|
|
final Set<AssetEntity> allUniqueAssets;
|
|
|
|
|
|
|
|
/// All assets from the selected albums that have been backup
|
|
|
|
final Set<String> selectedAlbumsBackupAssetsIds;
|
|
|
|
|
|
|
|
const BackUpState({
|
|
|
|
required this.backupProgress,
|
2022-06-25 22:12:47 +02:00
|
|
|
required this.allAssetsInDatabase,
|
2022-05-06 14:22:23 +02:00
|
|
|
required this.progressInPercentage,
|
|
|
|
required this.cancelToken,
|
|
|
|
required this.serverInfo,
|
|
|
|
required this.availableAlbums,
|
|
|
|
required this.selectedBackupAlbums,
|
|
|
|
required this.excludedBackupAlbums,
|
|
|
|
required this.allUniqueAssets,
|
|
|
|
required this.selectedAlbumsBackupAssetsIds,
|
|
|
|
});
|
|
|
|
|
|
|
|
BackUpState copyWith({
|
|
|
|
BackUpProgressEnum? backupProgress,
|
2022-06-25 22:12:47 +02:00
|
|
|
List<String>? allAssetsInDatabase,
|
2022-05-06 14:22:23 +02:00
|
|
|
double? progressInPercentage,
|
2022-06-18 14:36:58 +02:00
|
|
|
CancellationToken? cancelToken,
|
2022-05-06 14:22:23 +02:00
|
|
|
ServerInfo? serverInfo,
|
|
|
|
List<AvailableAlbum>? availableAlbums,
|
|
|
|
Set<AssetPathEntity>? selectedBackupAlbums,
|
|
|
|
Set<AssetPathEntity>? excludedBackupAlbums,
|
|
|
|
Set<AssetEntity>? allUniqueAssets,
|
|
|
|
Set<String>? selectedAlbumsBackupAssetsIds,
|
|
|
|
}) {
|
|
|
|
return BackUpState(
|
|
|
|
backupProgress: backupProgress ?? this.backupProgress,
|
2022-06-25 22:12:47 +02:00
|
|
|
allAssetsInDatabase: allAssetsInDatabase ?? this.allAssetsInDatabase,
|
2022-05-06 14:22:23 +02:00
|
|
|
progressInPercentage: progressInPercentage ?? this.progressInPercentage,
|
|
|
|
cancelToken: cancelToken ?? this.cancelToken,
|
|
|
|
serverInfo: serverInfo ?? this.serverInfo,
|
|
|
|
availableAlbums: availableAlbums ?? this.availableAlbums,
|
|
|
|
selectedBackupAlbums: selectedBackupAlbums ?? this.selectedBackupAlbums,
|
|
|
|
excludedBackupAlbums: excludedBackupAlbums ?? this.excludedBackupAlbums,
|
|
|
|
allUniqueAssets: allUniqueAssets ?? this.allUniqueAssets,
|
2022-06-25 22:12:47 +02:00
|
|
|
selectedAlbumsBackupAssetsIds:
|
|
|
|
selectedAlbumsBackupAssetsIds ?? this.selectedAlbumsBackupAssetsIds,
|
2022-05-06 14:22:23 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
2022-06-25 22:12:47 +02:00
|
|
|
return 'BackUpState(backupProgress: $backupProgress, allAssetsInDatabase: $allAssetsInDatabase, progressInPercentage: $progressInPercentage, cancelToken: $cancelToken, serverInfo: $serverInfo, availableAlbums: $availableAlbums, selectedBackupAlbums: $selectedBackupAlbums, excludedBackupAlbums: $excludedBackupAlbums, allUniqueAssets: $allUniqueAssets, selectedAlbumsBackupAssetsIds: $selectedAlbumsBackupAssetsIds)';
|
2022-05-06 14:22:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
List<Object> get props {
|
|
|
|
return [
|
|
|
|
backupProgress,
|
2022-06-25 22:12:47 +02:00
|
|
|
allAssetsInDatabase,
|
2022-05-06 14:22:23 +02:00
|
|
|
progressInPercentage,
|
|
|
|
cancelToken,
|
|
|
|
serverInfo,
|
|
|
|
availableAlbums,
|
|
|
|
selectedBackupAlbums,
|
|
|
|
excludedBackupAlbums,
|
|
|
|
allUniqueAssets,
|
|
|
|
selectedAlbumsBackupAssetsIds,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|