High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
fix(mobile): sync all album properties (#8332)
Fynn Petersen-Frey4ab4a35eba09
diff --git a/mobile/lib/shared/models/album.dart b/mobile/lib/shared/models/album.dartindex 3ed8f69eac..55c105c74b 100644--- a/mobile/lib/shared/models/album.dart+++ b/mobile/lib/shared/models/album.dart@@ -2,6 +2,7 @@ import 'package:flutter/foundation.dart';import 'package:immich_mobile/shared/models/asset.dart';import 'package:immich_mobile/shared/models/store.dart';import 'package:immich_mobile/shared/models/user.dart';+import 'package:immich_mobile/utils/datetime_comparison.dart';import 'package:isar/isar.dart';import 'package:openapi/api.dart';import 'package:photo_manager/photo_manager.dart';@@ -72,21 +73,18 @@ class Album {@overridebool operator ==(other) {if (other is! Album) return false;-- final lastModifiedAssetTimestampIsSetAndEqual =- lastModifiedAssetTimestamp != null &&- other.lastModifiedAssetTimestamp != null- ? lastModifiedAssetTimestamp!- .isAtSameMomentAs(other.lastModifiedAssetTimestamp!)- : true;-return id == other.id &&remoteId == other.remoteId &&localId == other.localId &&name == other.name &&createdAt.isAtSameMomentAs(other.createdAt) &&modifiedAt.isAtSameMomentAs(other.modifiedAt) &&- lastModifiedAssetTimestampIsSetAndEqual &&+ isAtSameMomentAs(startDate, other.startDate) &&+ isAtSameMomentAs(endDate, other.endDate) &&+ isAtSameMomentAs(+ lastModifiedAssetTimestamp,+ other.lastModifiedAssetTimestamp,+ ) &&shared == other.shared &&activityEnabled == other.activityEnabled &&owner.value == other.owner.value &&@@ -104,6 +102,8 @@ class Album {name.hashCode ^createdAt.hashCode ^modifiedAt.hashCode ^+ startDate.hashCode ^+ endDate.hashCode ^lastModifiedAssetTimestamp.hashCode ^shared.hashCode ^activityEnabled.hashCode ^diff --git a/mobile/lib/shared/services/sync.service.dart b/mobile/lib/shared/services/sync.service.dartindex a441091d37..e547eb012d 100644--- a/mobile/lib/shared/services/sync.service.dart+++ b/mobile/lib/shared/services/sync.service.dart@@ -12,6 +12,7 @@ import 'package:immich_mobile/shared/providers/db.provider.dart';import 'package:immich_mobile/shared/services/hash.service.dart';import 'package:immich_mobile/utils/async_mutex.dart';import 'package:immich_mobile/extensions/collection_extensions.dart';+import 'package:immich_mobile/utils/datetime_comparison.dart';import 'package:immich_mobile/utils/diff.dart';import 'package:isar/isar.dart';import 'package:logging/logging.dart';@@ -343,8 +344,13 @@ class SyncService {album.name = dto.albumName;album.shared = dto.shared;+ album.createdAt = dto.createdAt;album.modifiedAt = dto.updatedAt;+ album.startDate = dto.startDate;+ album.endDate = dto.endDate;album.lastModifiedAssetTimestamp = originalDto.lastModifiedAssetTimestamp;+ album.shared = dto.shared;+ album.activityEnabled = dto.isActivityEnabled;if (album.thumbnail.value?.remoteId != dto.albumThumbnailAssetId) {album.thumbnail.value = await _db.assets.where()@@ -863,12 +869,10 @@ bool _hasAlbumResponseDtoChanged(AlbumResponseDto dto, Album a) {dto.shared != a.shared ||dto.sharedUsers.length != a.sharedUsers.length ||!dto.updatedAt.isAtSameMomentAs(a.modifiedAt) ||- (dto.lastModifiedAssetTimestamp == null &&- a.lastModifiedAssetTimestamp != null) ||- (dto.lastModifiedAssetTimestamp != null &&- a.lastModifiedAssetTimestamp == null) ||- (dto.lastModifiedAssetTimestamp != null &&- a.lastModifiedAssetTimestamp != null &&- !dto.lastModifiedAssetTimestamp!- .isAtSameMomentAs(a.lastModifiedAssetTimestamp!));+ !isAtSameMomentAs(dto.startDate, a.startDate) ||+ !isAtSameMomentAs(dto.endDate, a.endDate) ||+ !isAtSameMomentAs(+ dto.lastModifiedAssetTimestamp,+ a.lastModifiedAssetTimestamp,+ );}diff --git a/mobile/lib/utils/datetime_comparison.dart b/mobile/lib/utils/datetime_comparison.dartnew file mode 100644index 0000000000..8c53ea45ba--- /dev/null+++ b/mobile/lib/utils/datetime_comparison.dart@@ -0,0 +1,3 @@+bool isAtSameMomentAs(DateTime? a, DateTime? b) =>+ (a == null && b == null) ||+ ((a != null && b != null) && a.isAtSameMomentAs(b));