refactor(mobile): entities and models (#9182)

* refactor(mobile): entities

* store entity

* refactor: models

* remove domain

* save all

* bad refactor
This commit is contained in:
Alex
2024-04-30 21:36:40 -05:00
committed by GitHub
parent eba42b245d
commit f057fe045e
237 changed files with 444 additions and 434 deletions

View File

@@ -0,0 +1,77 @@
import 'package:immich_mobile/entities/user.entity.dart';
import 'package:openapi/api.dart';
enum ActivityType { comment, like }
class Activity {
final String id;
final String? assetId;
final String? comment;
final DateTime createdAt;
final ActivityType type;
final User user;
const Activity({
required this.id,
this.assetId,
this.comment,
required this.createdAt,
required this.type,
required this.user,
});
Activity copyWith({
String? id,
String? assetId,
String? comment,
DateTime? createdAt,
ActivityType? type,
User? user,
}) {
return Activity(
id: id ?? this.id,
assetId: assetId ?? this.assetId,
comment: comment ?? this.comment,
createdAt: createdAt ?? this.createdAt,
type: type ?? this.type,
user: user ?? this.user,
);
}
Activity.fromDto(ActivityResponseDto dto)
: id = dto.id,
assetId = dto.assetId,
comment = dto.comment,
createdAt = dto.createdAt,
type = dto.type == ActivityResponseDtoTypeEnum.comment
? ActivityType.comment
: ActivityType.like,
user = User.fromSimpleUserDto(dto.user);
@override
String toString() {
return 'Activity(id: $id, assetId: $assetId, comment: $comment, createdAt: $createdAt, type: $type, user: $user)';
}
@override
bool operator ==(covariant Activity other) {
if (identical(this, other)) return true;
return other.id == id &&
other.assetId == assetId &&
other.comment == comment &&
other.createdAt == createdAt &&
other.type == type &&
other.user == user;
}
@override
int get hashCode {
return id.hashCode ^
assetId.hashCode ^
comment.hashCode ^
createdAt.hashCode ^
type.hashCode ^
user.hashCode;
}
}

View File

@@ -0,0 +1,49 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'dart:convert';
import 'package:collection/collection.dart';
class AlbumAddAssetsResponse {
List<String> alreadyInAlbum;
int successfullyAdded;
AlbumAddAssetsResponse({
required this.alreadyInAlbum,
required this.successfullyAdded,
});
AlbumAddAssetsResponse copyWith({
List<String>? alreadyInAlbum,
int? successfullyAdded,
}) {
return AlbumAddAssetsResponse(
alreadyInAlbum: alreadyInAlbum ?? this.alreadyInAlbum,
successfullyAdded: successfullyAdded ?? this.successfullyAdded,
);
}
Map<String, dynamic> toMap() {
return <String, dynamic>{
'alreadyInAlbum': alreadyInAlbum,
'successfullyAdded': successfullyAdded,
};
}
String toJson() => json.encode(toMap());
@override
String toString() =>
'AddAssetsResponse(alreadyInAlbum: $alreadyInAlbum, successfullyAdded: $successfullyAdded)';
@override
bool operator ==(covariant AlbumAddAssetsResponse other) {
if (identical(this, other)) return true;
final listEquals = const DeepCollectionEquality().equals;
return listEquals(other.alreadyInAlbum, alreadyInAlbum) &&
other.successfullyAdded == successfullyAdded;
}
@override
int get hashCode => alreadyInAlbum.hashCode ^ successfullyAdded.hashCode;
}

View File

@@ -0,0 +1,57 @@
import 'dart:convert';
class AlbumViewerPageState {
final bool isEditAlbum;
final String editTitleText;
AlbumViewerPageState({
required this.isEditAlbum,
required this.editTitleText,
});
AlbumViewerPageState copyWith({
bool? isEditAlbum,
String? editTitleText,
}) {
return AlbumViewerPageState(
isEditAlbum: isEditAlbum ?? this.isEditAlbum,
editTitleText: editTitleText ?? this.editTitleText,
);
}
Map<String, dynamic> toMap() {
final result = <String, dynamic>{};
result.addAll({'isEditAlbum': isEditAlbum});
result.addAll({'editTitleText': editTitleText});
return result;
}
factory AlbumViewerPageState.fromMap(Map<String, dynamic> map) {
return AlbumViewerPageState(
isEditAlbum: map['isEditAlbum'] ?? false,
editTitleText: map['editTitleText'] ?? '',
);
}
String toJson() => json.encode(toMap());
factory AlbumViewerPageState.fromJson(String source) =>
AlbumViewerPageState.fromMap(json.decode(source));
@override
String toString() =>
'AlbumViewerPageState(isEditAlbum: $isEditAlbum, editTitleText: $editTitleText)';
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is AlbumViewerPageState &&
other.isEditAlbum == isEditAlbum &&
other.editTitleText == editTitleText;
}
@override
int get hashCode => isEditAlbum.hashCode ^ editTitleText.hashCode;
}

View File

@@ -0,0 +1,21 @@
import 'package:collection/collection.dart';
import 'package:immich_mobile/entities/asset.entity.dart';
class AssetSelectionPageResult {
final Set<Asset> selectedAssets;
AssetSelectionPageResult({
required this.selectedAssets,
});
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
final setEquals = const DeepCollectionEquality().equals;
return other is AssetSelectionPageResult &&
setEquals(other.selectedAssets, selectedAssets);
}
@override
int get hashCode => selectedAssets.hashCode;
}

View File

@@ -0,0 +1,56 @@
import 'package:immich_mobile/entities/asset.entity.dart';
class AssetSelectionState {
final bool hasRemote;
final bool hasLocal;
final bool hasMerged;
final int selectedCount;
const AssetSelectionState({
this.hasRemote = false,
this.hasLocal = false,
this.hasMerged = false,
this.selectedCount = 0,
});
AssetSelectionState copyWith({
bool? hasRemote,
bool? hasLocal,
bool? hasMerged,
int? selectedCount,
}) {
return AssetSelectionState(
hasRemote: hasRemote ?? this.hasRemote,
hasLocal: hasLocal ?? this.hasLocal,
hasMerged: hasMerged ?? this.hasMerged,
selectedCount: selectedCount ?? this.selectedCount,
);
}
AssetSelectionState.fromSelection(Set<Asset> selection)
: hasLocal = selection.any((e) => e.storage == AssetState.local),
hasMerged = selection.any((e) => e.storage == AssetState.merged),
hasRemote = selection.any((e) => e.storage == AssetState.remote),
selectedCount = selection.length;
@override
String toString() =>
'SelectionAssetState(hasRemote: $hasRemote, hasMerged: $hasMerged, hasMerged: $hasMerged, selectedCount: $selectedCount)';
@override
bool operator ==(covariant AssetSelectionState other) {
if (identical(this, other)) return true;
return other.hasRemote == hasRemote &&
other.hasLocal == hasLocal &&
other.hasMerged == hasMerged &&
other.selectedCount == selectedCount;
}
@override
int get hashCode =>
hasRemote.hashCode ^
hasLocal.hashCode ^
hasMerged.hashCode ^
selectedCount.hashCode;
}

View File

@@ -0,0 +1,55 @@
import 'dart:convert';
enum DownloadAssetStatus { idle, loading, success, error }
class AssetViewerPageState {
// enum
final DownloadAssetStatus downloadAssetStatus;
AssetViewerPageState({
required this.downloadAssetStatus,
});
AssetViewerPageState copyWith({
DownloadAssetStatus? downloadAssetStatus,
}) {
return AssetViewerPageState(
downloadAssetStatus: downloadAssetStatus ?? this.downloadAssetStatus,
);
}
Map<String, dynamic> toMap() {
final result = <String, dynamic>{};
result.addAll({'downloadAssetStatus': downloadAssetStatus.index});
return result;
}
factory AssetViewerPageState.fromMap(Map<String, dynamic> map) {
return AssetViewerPageState(
downloadAssetStatus:
DownloadAssetStatus.values[map['downloadAssetStatus'] ?? 0],
);
}
String toJson() => json.encode(toMap());
factory AssetViewerPageState.fromJson(String source) =>
AssetViewerPageState.fromMap(json.decode(source));
@override
String toString() =>
'ImageViewerPageState(downloadAssetStatus: $downloadAssetStatus)';
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is AssetViewerPageState &&
other.downloadAssetStatus == downloadAssetStatus;
}
@override
int get hashCode => downloadAssetStatus.hashCode;
}

View File

@@ -0,0 +1,74 @@
class AuthenticationState {
final String deviceId;
final String userId;
final String userEmail;
final bool isAuthenticated;
final String name;
final bool isAdmin;
final bool shouldChangePassword;
final String profileImagePath;
AuthenticationState({
required this.deviceId,
required this.userId,
required this.userEmail,
required this.isAuthenticated,
required this.name,
required this.isAdmin,
required this.shouldChangePassword,
required this.profileImagePath,
});
AuthenticationState copyWith({
String? deviceId,
String? userId,
String? userEmail,
bool? isAuthenticated,
String? name,
bool? isAdmin,
bool? shouldChangePassword,
String? profileImagePath,
}) {
return AuthenticationState(
deviceId: deviceId ?? this.deviceId,
userId: userId ?? this.userId,
userEmail: userEmail ?? this.userEmail,
isAuthenticated: isAuthenticated ?? this.isAuthenticated,
name: name ?? this.name,
isAdmin: isAdmin ?? this.isAdmin,
shouldChangePassword: shouldChangePassword ?? this.shouldChangePassword,
profileImagePath: profileImagePath ?? this.profileImagePath,
);
}
@override
String toString() {
return 'AuthenticationState(deviceId: $deviceId, userId: $userId, userEmail: $userEmail, isAuthenticated: $isAuthenticated, name: $name, isAdmin: $isAdmin, shouldChangePassword: $shouldChangePassword, profileImagePath: $profileImagePath)';
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is AuthenticationState &&
other.deviceId == deviceId &&
other.userId == userId &&
other.userEmail == userEmail &&
other.isAuthenticated == isAuthenticated &&
other.name == name &&
other.isAdmin == isAdmin &&
other.shouldChangePassword == shouldChangePassword &&
other.profileImagePath == profileImagePath;
}
@override
int get hashCode {
return deviceId.hashCode ^
userId.hashCode ^
userEmail.hashCode ^
isAuthenticated.hashCode ^
name.hashCode ^
isAdmin.hashCode ^
shouldChangePassword.hashCode ^
profileImagePath.hashCode;
}
}

View File

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

View File

@@ -0,0 +1,195 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:cancellation_token_http/http.dart';
import 'package:collection/collection.dart';
import 'package:photo_manager/photo_manager.dart';
import 'package:immich_mobile/models/backup/available_album.model.dart';
import 'package:immich_mobile/models/backup/current_upload_asset.model.dart';
import 'package:immich_mobile/models/server_info/server_disk_info.model.dart';
enum BackUpProgressEnum {
idle,
inProgress,
manualInProgress,
inBackground,
done
}
class BackUpState {
// enum
final BackUpProgressEnum backupProgress;
final List<String> allAssetsInDatabase;
final double progressInPercentage;
final String progressInFileSize;
final double progressInFileSpeed;
final List<double> progressInFileSpeeds;
final DateTime progressInFileSpeedUpdateTime;
final int progressInFileSpeedUpdateSentBytes;
final double iCloudDownloadProgress;
final CancellationToken cancelToken;
final ServerDiskInfo serverInfo;
final bool autoBackup;
final bool backgroundBackup;
final bool backupRequireWifi;
final bool backupRequireCharging;
final int backupTriggerDelay;
/// All available albums on the device
final List<AvailableAlbum> availableAlbums;
final Set<AvailableAlbum> selectedBackupAlbums;
final Set<AvailableAlbum> 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;
// Current Backup Asset
final CurrentUploadAsset currentUploadAsset;
const BackUpState({
required this.backupProgress,
required this.allAssetsInDatabase,
required this.progressInPercentage,
required this.progressInFileSize,
required this.progressInFileSpeed,
required this.progressInFileSpeeds,
required this.progressInFileSpeedUpdateTime,
required this.progressInFileSpeedUpdateSentBytes,
required this.iCloudDownloadProgress,
required this.cancelToken,
required this.serverInfo,
required this.autoBackup,
required this.backgroundBackup,
required this.backupRequireWifi,
required this.backupRequireCharging,
required this.backupTriggerDelay,
required this.availableAlbums,
required this.selectedBackupAlbums,
required this.excludedBackupAlbums,
required this.allUniqueAssets,
required this.selectedAlbumsBackupAssetsIds,
required this.currentUploadAsset,
});
BackUpState copyWith({
BackUpProgressEnum? backupProgress,
List<String>? allAssetsInDatabase,
double? progressInPercentage,
String? progressInFileSize,
double? progressInFileSpeed,
List<double>? progressInFileSpeeds,
DateTime? progressInFileSpeedUpdateTime,
int? progressInFileSpeedUpdateSentBytes,
double? iCloudDownloadProgress,
CancellationToken? cancelToken,
ServerDiskInfo? serverInfo,
bool? autoBackup,
bool? backgroundBackup,
bool? backupRequireWifi,
bool? backupRequireCharging,
int? backupTriggerDelay,
List<AvailableAlbum>? availableAlbums,
Set<AvailableAlbum>? selectedBackupAlbums,
Set<AvailableAlbum>? excludedBackupAlbums,
Set<AssetEntity>? allUniqueAssets,
Set<String>? selectedAlbumsBackupAssetsIds,
CurrentUploadAsset? currentUploadAsset,
}) {
return BackUpState(
backupProgress: backupProgress ?? this.backupProgress,
allAssetsInDatabase: allAssetsInDatabase ?? this.allAssetsInDatabase,
progressInPercentage: progressInPercentage ?? this.progressInPercentage,
progressInFileSize: progressInFileSize ?? this.progressInFileSize,
progressInFileSpeed: progressInFileSpeed ?? this.progressInFileSpeed,
progressInFileSpeeds: progressInFileSpeeds ?? this.progressInFileSpeeds,
progressInFileSpeedUpdateTime:
progressInFileSpeedUpdateTime ?? this.progressInFileSpeedUpdateTime,
progressInFileSpeedUpdateSentBytes: progressInFileSpeedUpdateSentBytes ??
this.progressInFileSpeedUpdateSentBytes,
iCloudDownloadProgress:
iCloudDownloadProgress ?? this.iCloudDownloadProgress,
cancelToken: cancelToken ?? this.cancelToken,
serverInfo: serverInfo ?? this.serverInfo,
autoBackup: autoBackup ?? this.autoBackup,
backgroundBackup: backgroundBackup ?? this.backgroundBackup,
backupRequireWifi: backupRequireWifi ?? this.backupRequireWifi,
backupRequireCharging:
backupRequireCharging ?? this.backupRequireCharging,
backupTriggerDelay: backupTriggerDelay ?? this.backupTriggerDelay,
availableAlbums: availableAlbums ?? this.availableAlbums,
selectedBackupAlbums: selectedBackupAlbums ?? this.selectedBackupAlbums,
excludedBackupAlbums: excludedBackupAlbums ?? this.excludedBackupAlbums,
allUniqueAssets: allUniqueAssets ?? this.allUniqueAssets,
selectedAlbumsBackupAssetsIds:
selectedAlbumsBackupAssetsIds ?? this.selectedAlbumsBackupAssetsIds,
currentUploadAsset: currentUploadAsset ?? this.currentUploadAsset,
);
}
@override
String toString() {
return 'BackUpState(backupProgress: $backupProgress, allAssetsInDatabase: $allAssetsInDatabase, progressInPercentage: $progressInPercentage, progressInFileSize: $progressInFileSize, progressInFileSpeed: $progressInFileSpeed, progressInFileSpeeds: $progressInFileSpeeds, progressInFileSpeedUpdateTime: $progressInFileSpeedUpdateTime, progressInFileSpeedUpdateSentBytes: $progressInFileSpeedUpdateSentBytes, iCloudDownloadProgress: $iCloudDownloadProgress, cancelToken: $cancelToken, serverInfo: $serverInfo, autoBackup: $autoBackup, backgroundBackup: $backgroundBackup, backupRequireWifi: $backupRequireWifi, backupRequireCharging: $backupRequireCharging, backupTriggerDelay: $backupTriggerDelay, availableAlbums: $availableAlbums, selectedBackupAlbums: $selectedBackupAlbums, excludedBackupAlbums: $excludedBackupAlbums, allUniqueAssets: $allUniqueAssets, selectedAlbumsBackupAssetsIds: $selectedAlbumsBackupAssetsIds, currentUploadAsset: $currentUploadAsset)';
}
@override
bool operator ==(covariant BackUpState other) {
if (identical(this, other)) return true;
final collectionEquals = const DeepCollectionEquality().equals;
return other.backupProgress == backupProgress &&
collectionEquals(other.allAssetsInDatabase, allAssetsInDatabase) &&
other.progressInPercentage == progressInPercentage &&
other.progressInFileSize == progressInFileSize &&
other.progressInFileSpeed == progressInFileSpeed &&
collectionEquals(other.progressInFileSpeeds, progressInFileSpeeds) &&
other.progressInFileSpeedUpdateTime == progressInFileSpeedUpdateTime &&
other.progressInFileSpeedUpdateSentBytes ==
progressInFileSpeedUpdateSentBytes &&
other.iCloudDownloadProgress == iCloudDownloadProgress &&
other.cancelToken == cancelToken &&
other.serverInfo == serverInfo &&
other.autoBackup == autoBackup &&
other.backgroundBackup == backgroundBackup &&
other.backupRequireWifi == backupRequireWifi &&
other.backupRequireCharging == backupRequireCharging &&
other.backupTriggerDelay == backupTriggerDelay &&
collectionEquals(other.availableAlbums, availableAlbums) &&
collectionEquals(other.selectedBackupAlbums, selectedBackupAlbums) &&
collectionEquals(other.excludedBackupAlbums, excludedBackupAlbums) &&
collectionEquals(other.allUniqueAssets, allUniqueAssets) &&
collectionEquals(
other.selectedAlbumsBackupAssetsIds,
selectedAlbumsBackupAssetsIds,
) &&
other.currentUploadAsset == currentUploadAsset;
}
@override
int get hashCode {
return backupProgress.hashCode ^
allAssetsInDatabase.hashCode ^
progressInPercentage.hashCode ^
progressInFileSize.hashCode ^
progressInFileSpeed.hashCode ^
progressInFileSpeeds.hashCode ^
progressInFileSpeedUpdateTime.hashCode ^
progressInFileSpeedUpdateSentBytes.hashCode ^
iCloudDownloadProgress.hashCode ^
cancelToken.hashCode ^
serverInfo.hashCode ^
autoBackup.hashCode ^
backgroundBackup.hashCode ^
backupRequireWifi.hashCode ^
backupRequireCharging.hashCode ^
backupTriggerDelay.hashCode ^
availableAlbums.hashCode ^
selectedBackupAlbums.hashCode ^
excludedBackupAlbums.hashCode ^
allUniqueAssets.hashCode ^
selectedAlbumsBackupAssetsIds.hashCode ^
currentUploadAsset.hashCode;
}
}

View File

@@ -0,0 +1,94 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'dart:convert';
class CurrentUploadAsset {
final String id;
final DateTime fileCreatedAt;
final String fileName;
final String fileType;
final int? fileSize;
final bool? iCloudAsset;
CurrentUploadAsset({
required this.id,
required this.fileCreatedAt,
required this.fileName,
required this.fileType,
this.fileSize,
this.iCloudAsset,
});
CurrentUploadAsset copyWith({
String? id,
DateTime? fileCreatedAt,
String? fileName,
String? fileType,
int? fileSize,
bool? iCloudAsset,
}) {
return CurrentUploadAsset(
id: id ?? this.id,
fileCreatedAt: fileCreatedAt ?? this.fileCreatedAt,
fileName: fileName ?? this.fileName,
fileType: fileType ?? this.fileType,
fileSize: fileSize ?? this.fileSize,
iCloudAsset: iCloudAsset ?? this.iCloudAsset,
);
}
Map<String, dynamic> toMap() {
return <String, dynamic>{
'id': id,
'fileCreatedAt': fileCreatedAt.millisecondsSinceEpoch,
'fileName': fileName,
'fileType': fileType,
'fileSize': fileSize,
'iCloudAsset': iCloudAsset,
};
}
factory CurrentUploadAsset.fromMap(Map<String, dynamic> map) {
return CurrentUploadAsset(
id: map['id'] as String,
fileCreatedAt:
DateTime.fromMillisecondsSinceEpoch(map['fileCreatedAt'] as int),
fileName: map['fileName'] as String,
fileType: map['fileType'] as String,
fileSize: map['fileSize'] as int,
iCloudAsset:
map['iCloudAsset'] != null ? map['iCloudAsset'] as bool : null,
);
}
String toJson() => json.encode(toMap());
factory CurrentUploadAsset.fromJson(String source) =>
CurrentUploadAsset.fromMap(json.decode(source) as Map<String, dynamic>);
@override
String toString() {
return 'CurrentUploadAsset(id: $id, fileCreatedAt: $fileCreatedAt, fileName: $fileName, fileType: $fileType, fileSize: $fileSize, iCloudAsset: $iCloudAsset)';
}
@override
bool operator ==(covariant CurrentUploadAsset other) {
if (identical(this, other)) return true;
return other.id == id &&
other.fileCreatedAt == fileCreatedAt &&
other.fileName == fileName &&
other.fileType == fileType &&
other.fileSize == fileSize &&
other.iCloudAsset == iCloudAsset;
}
@override
int get hashCode {
return id.hashCode ^
fileCreatedAt.hashCode ^
fileName.hashCode ^
fileType.hashCode ^
fileSize.hashCode ^
iCloudAsset.hashCode;
}
}

View File

@@ -0,0 +1,65 @@
import 'package:photo_manager/photo_manager.dart';
class ErrorUploadAsset {
final String id;
final DateTime fileCreatedAt;
final String fileName;
final String fileType;
final AssetEntity asset;
final String errorMessage;
const ErrorUploadAsset({
required this.id,
required this.fileCreatedAt,
required this.fileName,
required this.fileType,
required this.asset,
required this.errorMessage,
});
ErrorUploadAsset copyWith({
String? id,
DateTime? fileCreatedAt,
String? fileName,
String? fileType,
AssetEntity? asset,
String? errorMessage,
}) {
return ErrorUploadAsset(
id: id ?? this.id,
fileCreatedAt: fileCreatedAt ?? this.fileCreatedAt,
fileName: fileName ?? this.fileName,
fileType: fileType ?? this.fileType,
asset: asset ?? this.asset,
errorMessage: errorMessage ?? this.errorMessage,
);
}
@override
String toString() {
return 'ErrorUploadAsset(id: $id, fileCreatedAt: $fileCreatedAt, fileName: $fileName, fileType: $fileType, asset: $asset, errorMessage: $errorMessage)';
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is ErrorUploadAsset &&
other.id == id &&
other.fileCreatedAt == fileCreatedAt &&
other.fileName == fileName &&
other.fileType == fileType &&
other.asset == asset &&
other.errorMessage == errorMessage;
}
@override
int get hashCode {
return id.hashCode ^
fileCreatedAt.hashCode ^
fileName.hashCode ^
fileType.hashCode ^
asset.hashCode ^
errorMessage.hashCode;
}
}

View File

@@ -0,0 +1,114 @@
import 'package:cancellation_token_http/http.dart';
import 'package:collection/collection.dart';
import 'package:immich_mobile/models/backup/current_upload_asset.model.dart';
class ManualUploadState {
final CancellationToken cancelToken;
// Current Backup Asset
final CurrentUploadAsset currentUploadAsset;
final int currentAssetIndex;
final bool showDetailedNotification;
/// Manual Upload Stats
final int totalAssetsToUpload;
final int successfulUploads;
final double progressInPercentage;
final String progressInFileSize;
final double progressInFileSpeed;
final List<double> progressInFileSpeeds;
final DateTime progressInFileSpeedUpdateTime;
final int progressInFileSpeedUpdateSentBytes;
const ManualUploadState({
required this.progressInPercentage,
required this.progressInFileSize,
required this.progressInFileSpeed,
required this.progressInFileSpeeds,
required this.progressInFileSpeedUpdateTime,
required this.progressInFileSpeedUpdateSentBytes,
required this.cancelToken,
required this.currentUploadAsset,
required this.totalAssetsToUpload,
required this.currentAssetIndex,
required this.successfulUploads,
required this.showDetailedNotification,
});
ManualUploadState copyWith({
double? progressInPercentage,
String? progressInFileSize,
double? progressInFileSpeed,
List<double>? progressInFileSpeeds,
DateTime? progressInFileSpeedUpdateTime,
int? progressInFileSpeedUpdateSentBytes,
CancellationToken? cancelToken,
CurrentUploadAsset? currentUploadAsset,
int? totalAssetsToUpload,
int? successfulUploads,
int? currentAssetIndex,
bool? showDetailedNotification,
}) {
return ManualUploadState(
progressInPercentage: progressInPercentage ?? this.progressInPercentage,
progressInFileSize: progressInFileSize ?? this.progressInFileSize,
progressInFileSpeed: progressInFileSpeed ?? this.progressInFileSpeed,
progressInFileSpeeds: progressInFileSpeeds ?? this.progressInFileSpeeds,
progressInFileSpeedUpdateTime:
progressInFileSpeedUpdateTime ?? this.progressInFileSpeedUpdateTime,
progressInFileSpeedUpdateSentBytes: progressInFileSpeedUpdateSentBytes ??
this.progressInFileSpeedUpdateSentBytes,
cancelToken: cancelToken ?? this.cancelToken,
currentUploadAsset: currentUploadAsset ?? this.currentUploadAsset,
totalAssetsToUpload: totalAssetsToUpload ?? this.totalAssetsToUpload,
currentAssetIndex: currentAssetIndex ?? this.currentAssetIndex,
successfulUploads: successfulUploads ?? this.successfulUploads,
showDetailedNotification:
showDetailedNotification ?? this.showDetailedNotification,
);
}
@override
String toString() {
return 'ManualUploadState(progressInPercentage: $progressInPercentage, progressInFileSize: $progressInFileSize, progressInFileSpeed: $progressInFileSpeed, progressInFileSpeeds: $progressInFileSpeeds, progressInFileSpeedUpdateTime: $progressInFileSpeedUpdateTime, progressInFileSpeedUpdateSentBytes: $progressInFileSpeedUpdateSentBytes, cancelToken: $cancelToken, currentUploadAsset: $currentUploadAsset, totalAssetsToUpload: $totalAssetsToUpload, successfulUploads: $successfulUploads, currentAssetIndex: $currentAssetIndex, showDetailedNotification: $showDetailedNotification)';
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
final collectionEquals = const DeepCollectionEquality().equals;
return other is ManualUploadState &&
other.progressInPercentage == progressInPercentage &&
other.progressInFileSize == progressInFileSize &&
other.progressInFileSpeed == progressInFileSpeed &&
collectionEquals(other.progressInFileSpeeds, progressInFileSpeeds) &&
other.progressInFileSpeedUpdateTime == progressInFileSpeedUpdateTime &&
other.progressInFileSpeedUpdateSentBytes ==
progressInFileSpeedUpdateSentBytes &&
other.cancelToken == cancelToken &&
other.currentUploadAsset == currentUploadAsset &&
other.totalAssetsToUpload == totalAssetsToUpload &&
other.currentAssetIndex == currentAssetIndex &&
other.successfulUploads == successfulUploads &&
other.showDetailedNotification == showDetailedNotification;
}
@override
int get hashCode {
return progressInPercentage.hashCode ^
progressInFileSize.hashCode ^
progressInFileSpeed.hashCode ^
progressInFileSpeeds.hashCode ^
progressInFileSpeedUpdateTime.hashCode ^
progressInFileSpeedUpdateSentBytes.hashCode ^
cancelToken.hashCode ^
currentUploadAsset.hashCode ^
totalAssetsToUpload.hashCode ^
currentAssetIndex.hashCode ^
successfulUploads.hashCode ^
showDetailedNotification.hashCode;
}
}

View File

@@ -0,0 +1,13 @@
// ignore_for_file: add-copy-with
sealed class MapEvent {
const MapEvent();
}
class MapAssetsInBoundsUpdated extends MapEvent {
final List<String> assetRemoteIds;
const MapAssetsInBoundsUpdated(this.assetRemoteIds);
}
class MapCloseBottomSheet extends MapEvent {}

View File

@@ -0,0 +1,39 @@
import 'package:maplibre_gl/maplibre_gl.dart';
import 'package:openapi/api.dart';
class MapMarker {
final LatLng latLng;
final String assetRemoteId;
MapMarker({
required this.latLng,
required this.assetRemoteId,
});
MapMarker copyWith({
LatLng? latLng,
String? assetRemoteId,
}) {
return MapMarker(
latLng: latLng ?? this.latLng,
assetRemoteId: assetRemoteId ?? this.assetRemoteId,
);
}
MapMarker.fromDto(MapMarkerResponseDto dto)
: latLng = LatLng(dto.lat, dto.lon),
assetRemoteId = dto.id;
@override
String toString() =>
'MapMarker(latLng: $latLng, assetRemoteId: $assetRemoteId)';
@override
bool operator ==(covariant MapMarker other) {
if (identical(this, other)) return true;
return other.latLng == latLng && other.assetRemoteId == assetRemoteId;
}
@override
int get hashCode => latLng.hashCode ^ assetRemoteId.hashCode;
}

View File

@@ -0,0 +1,77 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
class MapState {
final ThemeMode themeMode;
final bool showFavoriteOnly;
final bool includeArchived;
final bool withPartners;
final int relativeTime;
final bool shouldRefetchMarkers;
final AsyncValue<String> lightStyleFetched;
final AsyncValue<String> darkStyleFetched;
MapState({
this.themeMode = ThemeMode.system,
this.showFavoriteOnly = false,
this.includeArchived = false,
this.withPartners = false,
this.relativeTime = 0,
this.shouldRefetchMarkers = false,
this.lightStyleFetched = const AsyncLoading(),
this.darkStyleFetched = const AsyncLoading(),
});
MapState copyWith({
ThemeMode? themeMode,
bool? showFavoriteOnly,
bool? includeArchived,
bool? withPartners,
int? relativeTime,
bool? shouldRefetchMarkers,
AsyncValue<String>? lightStyleFetched,
AsyncValue<String>? darkStyleFetched,
}) {
return MapState(
themeMode: themeMode ?? this.themeMode,
showFavoriteOnly: showFavoriteOnly ?? this.showFavoriteOnly,
includeArchived: includeArchived ?? this.includeArchived,
withPartners: withPartners ?? this.withPartners,
relativeTime: relativeTime ?? this.relativeTime,
shouldRefetchMarkers: shouldRefetchMarkers ?? this.shouldRefetchMarkers,
lightStyleFetched: lightStyleFetched ?? this.lightStyleFetched,
darkStyleFetched: darkStyleFetched ?? this.darkStyleFetched,
);
}
@override
String toString() {
return 'MapState(themeMode: $themeMode, showFavoriteOnly: $showFavoriteOnly, includeArchived: $includeArchived, withPartners: $withPartners, relativeTime: $relativeTime, shouldRefetchMarkers: $shouldRefetchMarkers, lightStyleFetched: $lightStyleFetched, darkStyleFetched: $darkStyleFetched)';
}
@override
bool operator ==(covariant MapState other) {
if (identical(this, other)) return true;
return other.themeMode == themeMode &&
other.showFavoriteOnly == showFavoriteOnly &&
other.includeArchived == includeArchived &&
other.withPartners == withPartners &&
other.relativeTime == relativeTime &&
other.shouldRefetchMarkers == shouldRefetchMarkers &&
other.lightStyleFetched == lightStyleFetched &&
other.darkStyleFetched == darkStyleFetched;
}
@override
int get hashCode {
return themeMode.hashCode ^
showFavoriteOnly.hashCode ^
includeArchived.hashCode ^
withPartners.hashCode ^
relativeTime.hashCode ^
shouldRefetchMarkers.hashCode ^
lightStyleFetched.hashCode ^
darkStyleFetched.hashCode;
}
}

View File

@@ -0,0 +1,40 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:collection/collection.dart';
import 'package:immich_mobile/entities/asset.entity.dart';
class Memory {
final String title;
final List<Asset> assets;
Memory({
required this.title,
required this.assets,
});
Memory copyWith({
String? title,
List<Asset>? assets,
}) {
return Memory(
title: title ?? this.title,
assets: assets ?? this.assets,
);
}
@override
String toString() => 'Memory(title: $title, assets: $assets)';
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
final listEquals = const DeepCollectionEquality().equals;
return other is Memory &&
other.title == title &&
listEquals(other.assets, assets);
}
@override
int get hashCode => title.hashCode ^ assets.hashCode;
}

View File

@@ -0,0 +1,60 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'dart:convert';
/// A wrapper for [CuratedLocationsResponseDto] objects
/// and [CuratedObjectsResponseDto] to be displayed in
/// a view
class SearchCuratedContent {
/// The label to show associated with this curated object
final String label;
/// The id to lookup the asset from the server
final String id;
SearchCuratedContent({
required this.label,
required this.id,
});
SearchCuratedContent copyWith({
String? label,
String? id,
}) {
return SearchCuratedContent(
label: label ?? this.label,
id: id ?? this.id,
);
}
Map<String, dynamic> toMap() {
return <String, dynamic>{
'label': label,
'id': id,
};
}
factory SearchCuratedContent.fromMap(Map<String, dynamic> map) {
return SearchCuratedContent(
label: map['label'] as String,
id: map['id'] as String,
);
}
String toJson() => json.encode(toMap());
factory SearchCuratedContent.fromJson(String source) =>
SearchCuratedContent.fromMap(json.decode(source) as Map<String, dynamic>);
@override
String toString() => 'CuratedContent(label: $label, id: $id)';
@override
bool operator ==(covariant SearchCuratedContent other) {
if (identical(this, other)) return true;
return other.label == label && other.id == id;
}
@override
int get hashCode => label.hashCode ^ id.hashCode;
}

View File

@@ -0,0 +1,310 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'dart:convert';
import 'package:immich_mobile/entities/asset.entity.dart';
import 'package:openapi/api.dart';
class SearchLocationFilter {
String? country;
String? state;
String? city;
SearchLocationFilter({
this.country,
this.state,
this.city,
});
SearchLocationFilter copyWith({
String? country,
String? state,
String? city,
}) {
return SearchLocationFilter(
country: country ?? this.country,
state: state ?? this.state,
city: city ?? this.city,
);
}
Map<String, dynamic> toMap() {
return <String, dynamic>{
'country': country,
'state': state,
'city': city,
};
}
factory SearchLocationFilter.fromMap(Map<String, dynamic> map) {
return SearchLocationFilter(
country: map['country'] != null ? map['country'] as String : null,
state: map['state'] != null ? map['state'] as String : null,
city: map['city'] != null ? map['city'] as String : null,
);
}
String toJson() => json.encode(toMap());
factory SearchLocationFilter.fromJson(String source) =>
SearchLocationFilter.fromMap(json.decode(source) as Map<String, dynamic>);
@override
String toString() =>
'SearchLocationFilter(country: $country, state: $state, city: $city)';
@override
bool operator ==(covariant SearchLocationFilter other) {
if (identical(this, other)) return true;
return other.country == country &&
other.state == state &&
other.city == city;
}
@override
int get hashCode => country.hashCode ^ state.hashCode ^ city.hashCode;
}
class SearchCameraFilter {
String? make;
String? model;
SearchCameraFilter({
this.make,
this.model,
});
SearchCameraFilter copyWith({
String? make,
String? model,
}) {
return SearchCameraFilter(
make: make ?? this.make,
model: model ?? this.model,
);
}
Map<String, dynamic> toMap() {
return <String, dynamic>{
'make': make,
'model': model,
};
}
factory SearchCameraFilter.fromMap(Map<String, dynamic> map) {
return SearchCameraFilter(
make: map['make'] != null ? map['make'] as String : null,
model: map['model'] != null ? map['model'] as String : null,
);
}
String toJson() => json.encode(toMap());
factory SearchCameraFilter.fromJson(String source) =>
SearchCameraFilter.fromMap(json.decode(source) as Map<String, dynamic>);
@override
String toString() => 'SearchCameraFilter(make: $make, model: $model)';
@override
bool operator ==(covariant SearchCameraFilter other) {
if (identical(this, other)) return true;
return other.make == make && other.model == model;
}
@override
int get hashCode => make.hashCode ^ model.hashCode;
}
class SearchDateFilter {
DateTime? takenBefore;
DateTime? takenAfter;
SearchDateFilter({
this.takenBefore,
this.takenAfter,
});
SearchDateFilter copyWith({
DateTime? takenBefore,
DateTime? takenAfter,
}) {
return SearchDateFilter(
takenBefore: takenBefore ?? this.takenBefore,
takenAfter: takenAfter ?? this.takenAfter,
);
}
Map<String, dynamic> toMap() {
return <String, dynamic>{
'takenBefore': takenBefore?.millisecondsSinceEpoch,
'takenAfter': takenAfter?.millisecondsSinceEpoch,
};
}
factory SearchDateFilter.fromMap(Map<String, dynamic> map) {
return SearchDateFilter(
takenBefore: map['takenBefore'] != null
? DateTime.fromMillisecondsSinceEpoch(map['takenBefore'] as int)
: null,
takenAfter: map['takenAfter'] != null
? DateTime.fromMillisecondsSinceEpoch(map['takenAfter'] as int)
: null,
);
}
String toJson() => json.encode(toMap());
factory SearchDateFilter.fromJson(String source) =>
SearchDateFilter.fromMap(json.decode(source) as Map<String, dynamic>);
@override
String toString() =>
'SearchDateFilter(takenBefore: $takenBefore, takenAfter: $takenAfter)';
@override
bool operator ==(covariant SearchDateFilter other) {
if (identical(this, other)) return true;
return other.takenBefore == takenBefore && other.takenAfter == takenAfter;
}
@override
int get hashCode => takenBefore.hashCode ^ takenAfter.hashCode;
}
class SearchDisplayFilters {
bool isNotInAlbum = false;
bool isArchive = false;
bool isFavorite = false;
SearchDisplayFilters({
required this.isNotInAlbum,
required this.isArchive,
required this.isFavorite,
});
SearchDisplayFilters copyWith({
bool? isNotInAlbum,
bool? isArchive,
bool? isFavorite,
}) {
return SearchDisplayFilters(
isNotInAlbum: isNotInAlbum ?? this.isNotInAlbum,
isArchive: isArchive ?? this.isArchive,
isFavorite: isFavorite ?? this.isFavorite,
);
}
Map<String, dynamic> toMap() {
return <String, dynamic>{
'isNotInAlbum': isNotInAlbum,
'isArchive': isArchive,
'isFavorite': isFavorite,
};
}
factory SearchDisplayFilters.fromMap(Map<String, dynamic> map) {
return SearchDisplayFilters(
isNotInAlbum: map['isNotInAlbum'] as bool,
isArchive: map['isArchive'] as bool,
isFavorite: map['isFavorite'] as bool,
);
}
String toJson() => json.encode(toMap());
factory SearchDisplayFilters.fromJson(String source) =>
SearchDisplayFilters.fromMap(json.decode(source) as Map<String, dynamic>);
@override
String toString() =>
'SearchDisplayFilters(isNotInAlbum: $isNotInAlbum, isArchive: $isArchive, isFavorite: $isFavorite)';
@override
bool operator ==(covariant SearchDisplayFilters other) {
if (identical(this, other)) return true;
return other.isNotInAlbum == isNotInAlbum &&
other.isArchive == isArchive &&
other.isFavorite == isFavorite;
}
@override
int get hashCode =>
isNotInAlbum.hashCode ^ isArchive.hashCode ^ isFavorite.hashCode;
}
class SearchFilter {
String? context;
String? filename;
Set<PersonResponseDto> people;
SearchLocationFilter location;
SearchCameraFilter camera;
SearchDateFilter date;
SearchDisplayFilters display;
// Enum
AssetType mediaType;
SearchFilter({
this.context,
this.filename,
required this.people,
required this.location,
required this.camera,
required this.date,
required this.display,
required this.mediaType,
});
SearchFilter copyWith({
String? context,
String? filename,
Set<PersonResponseDto>? people,
SearchLocationFilter? location,
SearchCameraFilter? camera,
SearchDateFilter? date,
SearchDisplayFilters? display,
AssetType? mediaType,
}) {
return SearchFilter(
context: context ?? this.context,
filename: filename ?? this.filename,
people: people ?? this.people,
location: location ?? this.location,
camera: camera ?? this.camera,
date: date ?? this.date,
display: display ?? this.display,
mediaType: mediaType ?? this.mediaType,
);
}
@override
String toString() {
return 'SearchFilter(context: $context, filename: $filename, people: $people, location: $location, camera: $camera, date: $date, display: $display, mediaType: $mediaType)';
}
@override
bool operator ==(covariant SearchFilter other) {
if (identical(this, other)) return true;
return other.context == context &&
other.filename == filename &&
other.people == people &&
other.location == location &&
other.camera == camera &&
other.date == date &&
other.display == display &&
other.mediaType == mediaType;
}
@override
int get hashCode {
return context.hashCode ^
filename.hashCode ^
people.hashCode ^
location.hashCode ^
camera.hashCode ^
date.hashCode ^
display.hashCode ^
mediaType.hashCode;
}
}

View File

@@ -0,0 +1,61 @@
import 'package:collection/collection.dart';
import 'package:immich_mobile/entities/asset.entity.dart';
class SearchResultPageState {
final bool isLoading;
final bool isSuccess;
final bool isError;
final bool isSmart;
final List<Asset> searchResult;
SearchResultPageState({
required this.isLoading,
required this.isSuccess,
required this.isError,
required this.isSmart,
required this.searchResult,
});
SearchResultPageState copyWith({
bool? isLoading,
bool? isSuccess,
bool? isError,
bool? isSmart,
List<Asset>? searchResult,
}) {
return SearchResultPageState(
isLoading: isLoading ?? this.isLoading,
isSuccess: isSuccess ?? this.isSuccess,
isError: isError ?? this.isError,
isSmart: isSmart ?? this.isSmart,
searchResult: searchResult ?? this.searchResult,
);
}
@override
String toString() {
return 'SearchresultPageState(isLoading: $isLoading, isSuccess: $isSuccess, isError: $isError, isSmart: $isSmart, searchResult: $searchResult)';
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
final listEquals = const DeepCollectionEquality().equals;
return other is SearchResultPageState &&
other.isLoading == isLoading &&
other.isSuccess == isSuccess &&
other.isError == isError &&
other.isSmart == isSmart &&
listEquals(other.searchResult, searchResult);
}
@override
int get hashCode {
return isLoading.hashCode ^
isSuccess.hashCode ^
isError.hashCode ^
isSmart.hashCode ^
searchResult.hashCode;
}
}

View File

@@ -0,0 +1,47 @@
import 'package:openapi/api.dart';
class ServerConfig {
final int trashDays;
final String oauthButtonText;
final String externalDomain;
const ServerConfig({
required this.trashDays,
required this.oauthButtonText,
required this.externalDomain,
});
ServerConfig copyWith({
int? trashDays,
String? oauthButtonText,
String? externalDomain,
}) {
return ServerConfig(
trashDays: trashDays ?? this.trashDays,
oauthButtonText: oauthButtonText ?? this.oauthButtonText,
externalDomain: externalDomain ?? this.externalDomain,
);
}
@override
String toString() =>
'ServerConfig(trashDays: $trashDays, oauthButtonText: $oauthButtonText, externalDomain: $externalDomain)';
ServerConfig.fromDto(ServerConfigDto dto)
: trashDays = dto.trashDays,
oauthButtonText = dto.oauthButtonText,
externalDomain = dto.externalDomain;
@override
bool operator ==(covariant ServerConfig other) {
if (identical(this, other)) return true;
return other.trashDays == trashDays &&
other.oauthButtonText == oauthButtonText &&
other.externalDomain == externalDomain;
}
@override
int get hashCode =>
trashDays.hashCode ^ oauthButtonText.hashCode ^ externalDomain.hashCode;
}

View File

@@ -0,0 +1,59 @@
import 'package:openapi/api.dart';
class ServerDiskInfo {
final String diskAvailable;
final String diskSize;
final String diskUse;
final double diskUsagePercentage;
const ServerDiskInfo({
required this.diskAvailable,
required this.diskSize,
required this.diskUse,
required this.diskUsagePercentage,
});
ServerDiskInfo copyWith({
String? diskAvailable,
String? diskSize,
String? diskUse,
double? diskUsagePercentage,
}) {
return ServerDiskInfo(
diskAvailable: diskAvailable ?? this.diskAvailable,
diskSize: diskSize ?? this.diskSize,
diskUse: diskUse ?? this.diskUse,
diskUsagePercentage: diskUsagePercentage ?? this.diskUsagePercentage,
);
}
@override
String toString() {
return 'ServerDiskInfo(diskAvailable: $diskAvailable, diskSize: $diskSize, diskUse: $diskUse, diskUsagePercentage: $diskUsagePercentage)';
}
ServerDiskInfo.fromDto(ServerInfoResponseDto dto)
: diskAvailable = dto.diskAvailable,
diskSize = dto.diskSize,
diskUse = dto.diskUse,
diskUsagePercentage = dto.diskUsagePercentage;
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is ServerDiskInfo &&
other.diskAvailable == diskAvailable &&
other.diskSize == diskSize &&
other.diskUse == diskUse &&
other.diskUsagePercentage == diskUsagePercentage;
}
@override
int get hashCode {
return diskAvailable.hashCode ^
diskSize.hashCode ^
diskUse.hashCode ^
diskUsagePercentage.hashCode;
}
}

View File

@@ -0,0 +1,58 @@
import 'package:openapi/api.dart';
class ServerFeatures {
final bool trash;
final bool map;
final bool oauthEnabled;
final bool passwordLogin;
const ServerFeatures({
required this.trash,
required this.map,
required this.oauthEnabled,
required this.passwordLogin,
});
ServerFeatures copyWith({
bool? trash,
bool? map,
bool? oauthEnabled,
bool? passwordLogin,
}) {
return ServerFeatures(
trash: trash ?? this.trash,
map: map ?? this.map,
oauthEnabled: oauthEnabled ?? this.oauthEnabled,
passwordLogin: passwordLogin ?? this.passwordLogin,
);
}
@override
String toString() {
return 'ServerFeatures(trash: $trash, map: $map, oauthEnabled: $oauthEnabled, passwordLogin: $passwordLogin)';
}
ServerFeatures.fromDto(ServerFeaturesDto dto)
: trash = dto.trash,
map = dto.map,
oauthEnabled = dto.oauth,
passwordLogin = dto.passwordLogin;
@override
bool operator ==(covariant ServerFeatures other) {
if (identical(this, other)) return true;
return other.trash == trash &&
other.map == map &&
other.oauthEnabled == oauthEnabled &&
other.passwordLogin == passwordLogin;
}
@override
int get hashCode {
return trash.hashCode ^
map.hashCode ^
oauthEnabled.hashCode ^
passwordLogin.hashCode;
}
}

View File

@@ -0,0 +1,82 @@
import 'package:immich_mobile/models/server_info/server_config.model.dart';
import 'package:immich_mobile/models/server_info/server_disk_info.model.dart';
import 'package:immich_mobile/models/server_info/server_features.model.dart';
import 'package:immich_mobile/models/server_info/server_version.model.dart';
class ServerInfo {
final ServerVersion serverVersion;
final ServerVersion latestVersion;
final ServerFeatures serverFeatures;
final ServerConfig serverConfig;
final ServerDiskInfo serverDiskInfo;
final bool isVersionMismatch;
final bool isNewReleaseAvailable;
final String versionMismatchErrorMessage;
ServerInfo({
required this.serverVersion,
required this.latestVersion,
required this.serverFeatures,
required this.serverConfig,
required this.serverDiskInfo,
required this.isVersionMismatch,
required this.isNewReleaseAvailable,
required this.versionMismatchErrorMessage,
});
ServerInfo copyWith({
ServerVersion? serverVersion,
ServerVersion? latestVersion,
ServerFeatures? serverFeatures,
ServerConfig? serverConfig,
ServerDiskInfo? serverDiskInfo,
bool? isVersionMismatch,
bool? isNewReleaseAvailable,
String? versionMismatchErrorMessage,
}) {
return ServerInfo(
serverVersion: serverVersion ?? this.serverVersion,
latestVersion: latestVersion ?? this.latestVersion,
serverFeatures: serverFeatures ?? this.serverFeatures,
serverConfig: serverConfig ?? this.serverConfig,
serverDiskInfo: serverDiskInfo ?? this.serverDiskInfo,
isVersionMismatch: isVersionMismatch ?? this.isVersionMismatch,
isNewReleaseAvailable:
isNewReleaseAvailable ?? this.isNewReleaseAvailable,
versionMismatchErrorMessage:
versionMismatchErrorMessage ?? this.versionMismatchErrorMessage,
);
}
@override
String toString() {
return 'ServerInfo(serverVersion: $serverVersion, latestVersion: $latestVersion, serverFeatures: $serverFeatures, serverConfig: $serverConfig, serverDiskInfo: $serverDiskInfo, isVersionMismatch: $isVersionMismatch, isNewReleaseAvailable: $isNewReleaseAvailable, versionMismatchErrorMessage: $versionMismatchErrorMessage)';
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is ServerInfo &&
other.serverVersion == serverVersion &&
other.latestVersion == latestVersion &&
other.serverFeatures == serverFeatures &&
other.serverConfig == serverConfig &&
other.serverDiskInfo == serverDiskInfo &&
other.isVersionMismatch == isVersionMismatch &&
other.isNewReleaseAvailable == isNewReleaseAvailable &&
other.versionMismatchErrorMessage == versionMismatchErrorMessage;
}
@override
int get hashCode {
return serverVersion.hashCode ^
latestVersion.hashCode ^
serverFeatures.hashCode ^
serverConfig.hashCode ^
serverDiskInfo.hashCode ^
isVersionMismatch.hashCode ^
isNewReleaseAvailable.hashCode ^
versionMismatchErrorMessage.hashCode;
}
}

View File

@@ -0,0 +1,50 @@
import 'package:openapi/api.dart';
class ServerVersion {
final int major;
final int minor;
final int patch;
const ServerVersion({
required this.major,
required this.minor,
required this.patch,
});
ServerVersion copyWith({
int? major,
int? minor,
int? patch,
}) {
return ServerVersion(
major: major ?? this.major,
minor: minor ?? this.minor,
patch: patch ?? this.patch,
);
}
@override
String toString() {
return 'ServerVersion(major: $major, minor: $minor, patch: $patch)';
}
ServerVersion.fromDto(ServerVersionResponseDto dto)
: major = dto.major,
minor = dto.minor,
patch = dto.patch_;
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is ServerVersion &&
other.major == major &&
other.minor == minor &&
other.patch == patch;
}
@override
int get hashCode {
return major.hashCode ^ minor.hashCode ^ patch.hashCode;
}
}

View File

@@ -0,0 +1,114 @@
import 'package:openapi/api.dart';
enum SharedLinkSource { album, individual }
class SharedLink {
final String id;
final String title;
final bool allowDownload;
final bool allowUpload;
final String? thumbAssetId;
final String? description;
final String? password;
final DateTime? expiresAt;
final String key;
final bool showMetadata;
final SharedLinkSource type;
const SharedLink({
required this.id,
required this.title,
required this.allowDownload,
required this.allowUpload,
required this.thumbAssetId,
required this.description,
required this.password,
required this.expiresAt,
required this.key,
required this.showMetadata,
required this.type,
});
SharedLink copyWith({
String? id,
String? title,
String? thumbAssetId,
bool? allowDownload,
bool? allowUpload,
String? description,
String? password,
DateTime? expiresAt,
String? key,
bool? showMetadata,
SharedLinkSource? type,
}) {
return SharedLink(
id: id ?? this.id,
title: title ?? this.title,
thumbAssetId: thumbAssetId ?? this.thumbAssetId,
allowDownload: allowDownload ?? this.allowDownload,
allowUpload: allowUpload ?? this.allowUpload,
description: description ?? this.description,
password: password ?? this.password,
expiresAt: expiresAt ?? this.expiresAt,
key: key ?? this.key,
showMetadata: showMetadata ?? this.showMetadata,
type: type ?? this.type,
);
}
SharedLink.fromDto(SharedLinkResponseDto dto)
: id = dto.id,
allowDownload = dto.allowDownload,
allowUpload = dto.allowUpload,
description = dto.description,
password = dto.password,
expiresAt = dto.expiresAt,
key = dto.key,
showMetadata = dto.showMetadata,
type = dto.type == SharedLinkType.ALBUM
? SharedLinkSource.album
: SharedLinkSource.individual,
title = dto.type == SharedLinkType.ALBUM
? dto.album?.albumName.toUpperCase() ?? "UNKNOWN SHARE"
: "INDIVIDUAL SHARE",
thumbAssetId = dto.type == SharedLinkType.ALBUM
? dto.album?.albumThumbnailAssetId
: dto.assets.isNotEmpty
? dto.assets[0].id
: null;
@override
String toString() =>
'SharedLink(id=$id, title=$title, thumbAssetId=$thumbAssetId, allowDownload=$allowDownload, allowUpload=$allowUpload, description=$description, password=$password, expiresAt=$expiresAt, key=$key, showMetadata=$showMetadata, type=$type)';
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is SharedLink &&
other.id == id &&
other.title == title &&
other.thumbAssetId == thumbAssetId &&
other.allowDownload == allowDownload &&
other.allowUpload == allowUpload &&
other.description == description &&
other.password == password &&
other.expiresAt == expiresAt &&
other.key == key &&
other.showMetadata == showMetadata &&
other.type == type;
@override
int get hashCode =>
id.hashCode ^
title.hashCode ^
thumbAssetId.hashCode ^
allowDownload.hashCode ^
allowUpload.hashCode ^
description.hashCode ^
password.hashCode ^
expiresAt.hashCode ^
key.hashCode ^
showMetadata.hashCode ^
type.hashCode;
}