feat: full local assets / album sync
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user