Skip to content

High performance self-hosted photo and video management solution.

fix(mobile): Sorted shared album and added share user doesn't reflect change in album view (#1955)

Alex416e30ede22f
diff --git a/mobile/lib/modules/album/providers/shared_album.provider.dart b/mobile/lib/modules/album/providers/shared_album.provider.dart
index a1c83a95c2..24a57a993d 100644
--- a/mobile/lib/modules/album/providers/shared_album.provider.dart
+++ b/mobile/lib/modules/album/providers/shared_album.provider.dart
@@ -37,12 +37,20 @@ class SharedAlbumNotifier extends StateNotifier<List<Album>> {
}
Future<void> getAllSharedAlbums() async {
- var albums = await _db.albums.filter().sharedEqualTo(true).findAll();
+ var albums = await _db.albums
+ .filter()
+ .sharedEqualTo(true)
+ .sortByCreatedAtDesc()
+ .findAll();
if (!const ListEquality().equals(albums, state)) {
state = albums;
}
await _albumService.refreshRemoteAlbums(isShared: true);
- albums = await _db.albums.filter().sharedEqualTo(true).findAll();
+ albums = await _db.albums
+ .filter()
+ .sharedEqualTo(true)
+ .sortByCreatedAtDesc()
+ .findAll();
if (!const ListEquality().equals(albums, state)) {
state = albums;
}
diff --git a/mobile/lib/modules/album/services/album.service.dart b/mobile/lib/modules/album/services/album.service.dart
index 594bc163a9..a846c50dd1 100644
--- a/mobile/lib/modules/album/services/album.service.dart
+++ b/mobile/lib/modules/album/services/album.service.dart
@@ -211,7 +211,11 @@ class AlbumService {
if (result != null) {
album.sharedUsers
.addAll((await _db.users.getAllById(sharedUserIds)).cast());
- await _db.writeTxn(() => album.sharedUsers.save());
+ album.shared = result.shared;
+ await _db.writeTxn(() async {
+ await _db.albums.put(album);
+ await album.sharedUsers.save();
+ });
return true;
}
} catch (e) {
diff --git a/mobile/lib/shared/services/sync.service.dart b/mobile/lib/shared/services/sync.service.dart
index 57d565cfce..efe3856385 100644
--- a/mobile/lib/shared/services/sync.service.dart
+++ b/mobile/lib/shared/services/sync.service.dart
@@ -501,7 +501,6 @@ Triple<List<Asset>, List<Asset>, List<Asset>> _diffAssets(
(!a.isLocal && b.isLocal) ||
(!a.isRemote && b.isRemote)) {
toUpdate.add(b.updateFromDb(a));
- debugPrint("both");
return true;
}
return false;
@@ -554,5 +553,6 @@ bool _hasAlbumResponseDtoChanged(AlbumResponseDto dto, Album a) {
dto.albumName != a.name ||
dto.albumThumbnailAssetId != a.thumbnail.value?.remoteId ||
dto.shared != a.shared ||
+ dto.sharedUsers.length != a.sharedUsers.length ||
DateTime.parse(dto.updatedAt).toUtc() != a.modifiedAt.toUtc();
}