feat: full local assets / album sync

This commit is contained in:
shenlong-tanwen
2024-10-17 23:33:00 +05:30
parent a09710ec7b
commit c91a2878dc
87 changed files with 2417 additions and 366 deletions
+60 -9
View File
@@ -1,31 +1,82 @@
import 'package:flutter/foundation.dart';
import 'package:immich_mobile/utils/collection_util.dart';
@immutable
class LocalAlbum {
final int id;
final String localId;
class Album {
final int? id;
final String? localId;
final String? remoteId;
final String name;
final DateTime modifiedTime;
final int? thumbnailAssetId;
const LocalAlbum({
required this.id,
required this.localId,
bool get isRemote => remoteId != null;
bool get isLocal => localId != null;
const Album({
this.id,
this.localId,
this.remoteId,
required this.name,
required this.modifiedTime,
this.thumbnailAssetId,
});
@override
bool operator ==(covariant LocalAlbum other) {
bool operator ==(covariant Album other) {
if (identical(this, other)) return true;
return other.hashCode == hashCode;
return other.id == id &&
other.localId == localId &&
other.remoteId == remoteId &&
other.name == name &&
other.modifiedTime == modifiedTime &&
other.thumbnailAssetId == thumbnailAssetId;
}
@override
int get hashCode {
return id.hashCode ^
localId.hashCode ^
remoteId.hashCode ^
name.hashCode ^
modifiedTime.hashCode;
modifiedTime.hashCode ^
thumbnailAssetId.hashCode;
}
Album copyWith({
int? id,
String? localId,
String? remoteId,
String? name,
DateTime? modifiedTime,
int? thumbnailAssetId,
}) {
return Album(
id: id ?? this.id,
localId: localId ?? this.localId,
remoteId: remoteId ?? this.remoteId,
name: name ?? this.name,
modifiedTime: modifiedTime ?? this.modifiedTime,
thumbnailAssetId: thumbnailAssetId ?? this.thumbnailAssetId,
);
}
@override
String toString() => """
{
id: ${id ?? "-"},
localId: "${localId ?? "-"}",
remoteId: "${remoteId ?? "-"}",
name: $name,
modifiedTime:
$modifiedTime,
thumbnailAssetId: "${thumbnailAssetId ?? "-"}",
}""";
static int compareByLocalId(Album a, Album b) =>
CollectionUtil.compareToNullable(a.localId, b.localId);
static int compareByRemoteId(Album a, Album b) =>
CollectionUtil.compareToNullable(a.remoteId, b.remoteId);
}