1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-25 10:43:13 +02:00

fix(mobile): sync all album properties (#8332)

This commit is contained in:
Fynn Petersen-Frey 2024-04-02 07:22:15 +02:00 committed by GitHub
parent e5d9372708
commit 4ab4a35eba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 17 deletions

View File

@ -2,6 +2,7 @@ import 'package:flutter/foundation.dart';
import 'package:immich_mobile/shared/models/asset.dart'; import 'package:immich_mobile/shared/models/asset.dart';
import 'package:immich_mobile/shared/models/store.dart'; import 'package:immich_mobile/shared/models/store.dart';
import 'package:immich_mobile/shared/models/user.dart'; import 'package:immich_mobile/shared/models/user.dart';
import 'package:immich_mobile/utils/datetime_comparison.dart';
import 'package:isar/isar.dart'; import 'package:isar/isar.dart';
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
import 'package:photo_manager/photo_manager.dart'; import 'package:photo_manager/photo_manager.dart';
@ -72,21 +73,18 @@ class Album {
@override @override
bool operator ==(other) { bool operator ==(other) {
if (other is! Album) return false; if (other is! Album) return false;
final lastModifiedAssetTimestampIsSetAndEqual =
lastModifiedAssetTimestamp != null &&
other.lastModifiedAssetTimestamp != null
? lastModifiedAssetTimestamp!
.isAtSameMomentAs(other.lastModifiedAssetTimestamp!)
: true;
return id == other.id && return id == other.id &&
remoteId == other.remoteId && remoteId == other.remoteId &&
localId == other.localId && localId == other.localId &&
name == other.name && name == other.name &&
createdAt.isAtSameMomentAs(other.createdAt) && createdAt.isAtSameMomentAs(other.createdAt) &&
modifiedAt.isAtSameMomentAs(other.modifiedAt) && modifiedAt.isAtSameMomentAs(other.modifiedAt) &&
lastModifiedAssetTimestampIsSetAndEqual && isAtSameMomentAs(startDate, other.startDate) &&
isAtSameMomentAs(endDate, other.endDate) &&
isAtSameMomentAs(
lastModifiedAssetTimestamp,
other.lastModifiedAssetTimestamp,
) &&
shared == other.shared && shared == other.shared &&
activityEnabled == other.activityEnabled && activityEnabled == other.activityEnabled &&
owner.value == other.owner.value && owner.value == other.owner.value &&
@ -104,6 +102,8 @@ class Album {
name.hashCode ^ name.hashCode ^
createdAt.hashCode ^ createdAt.hashCode ^
modifiedAt.hashCode ^ modifiedAt.hashCode ^
startDate.hashCode ^
endDate.hashCode ^
lastModifiedAssetTimestamp.hashCode ^ lastModifiedAssetTimestamp.hashCode ^
shared.hashCode ^ shared.hashCode ^
activityEnabled.hashCode ^ activityEnabled.hashCode ^

View File

@ -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/shared/services/hash.service.dart';
import 'package:immich_mobile/utils/async_mutex.dart'; import 'package:immich_mobile/utils/async_mutex.dart';
import 'package:immich_mobile/extensions/collection_extensions.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:immich_mobile/utils/diff.dart';
import 'package:isar/isar.dart'; import 'package:isar/isar.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
@ -343,8 +344,13 @@ class SyncService {
album.name = dto.albumName; album.name = dto.albumName;
album.shared = dto.shared; album.shared = dto.shared;
album.createdAt = dto.createdAt;
album.modifiedAt = dto.updatedAt; album.modifiedAt = dto.updatedAt;
album.startDate = dto.startDate;
album.endDate = dto.endDate;
album.lastModifiedAssetTimestamp = originalDto.lastModifiedAssetTimestamp; album.lastModifiedAssetTimestamp = originalDto.lastModifiedAssetTimestamp;
album.shared = dto.shared;
album.activityEnabled = dto.isActivityEnabled;
if (album.thumbnail.value?.remoteId != dto.albumThumbnailAssetId) { if (album.thumbnail.value?.remoteId != dto.albumThumbnailAssetId) {
album.thumbnail.value = await _db.assets album.thumbnail.value = await _db.assets
.where() .where()
@ -863,12 +869,10 @@ bool _hasAlbumResponseDtoChanged(AlbumResponseDto dto, Album a) {
dto.shared != a.shared || dto.shared != a.shared ||
dto.sharedUsers.length != a.sharedUsers.length || dto.sharedUsers.length != a.sharedUsers.length ||
!dto.updatedAt.isAtSameMomentAs(a.modifiedAt) || !dto.updatedAt.isAtSameMomentAs(a.modifiedAt) ||
(dto.lastModifiedAssetTimestamp == null && !isAtSameMomentAs(dto.startDate, a.startDate) ||
a.lastModifiedAssetTimestamp != null) || !isAtSameMomentAs(dto.endDate, a.endDate) ||
(dto.lastModifiedAssetTimestamp != null && !isAtSameMomentAs(
a.lastModifiedAssetTimestamp == null) || dto.lastModifiedAssetTimestamp,
(dto.lastModifiedAssetTimestamp != null && a.lastModifiedAssetTimestamp,
a.lastModifiedAssetTimestamp != null && );
!dto.lastModifiedAssetTimestamp!
.isAtSameMomentAs(a.lastModifiedAssetTimestamp!));
} }

View File

@ -0,0 +1,3 @@
bool isAtSameMomentAs(DateTime? a, DateTime? b) =>
(a == null && b == null) ||
((a != null && b != null) && a.isAtSameMomentAs(b));