From 979ce90abf22c6cd80ff06f61a08d0c03092991b Mon Sep 17 00:00:00 2001 From: Tom graham Date: Wed, 8 Jan 2025 15:45:30 +1100 Subject: [PATCH] Fix issue with refreshRemoteAlbums getting shared items twice and removed incorrect isShared comment. Using `getAll(shared: true)` gets all shared albums the user can access (regardless of owner, despite the previous comment). Using `getAll(shared: null)` gets all albums (incuding shared = true and shared = false). I presume the intent here was to get albums that were shared (and not mine), and not shared (ie: mine), but the logic is way off. It also just then combines them - so makes more sense to just get them in a single call. --- mobile/lib/services/album.service.dart | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mobile/lib/services/album.service.dart b/mobile/lib/services/album.service.dart index f36ff7b9f0..161ce0bd71 100644 --- a/mobile/lib/services/album.service.dart +++ b/mobile/lib/services/album.service.dart @@ -157,7 +157,7 @@ class AlbumService { return result; } - /// Checks remote albums (owned if `isShared` is false) for changes, + /// Checks remote albums for changes, /// updates the local database and returns `true` if there were any changes Future refreshRemoteAlbums() async { if (!_remoteCompleter.isCompleted) { @@ -169,18 +169,14 @@ class AlbumService { bool changes = false; try { await _userService.refreshUsers(); - final (sharedAlbum, ownedAlbum) = await ( - _albumApiRepository.getAll(shared: true), - _albumApiRepository.getAll(shared: null) - ).wait; + final allAlbums = await _albumApiRepository.getAll(); final albums = HashSet( equals: (a, b) => a.remoteId == b.remoteId, hashCode: (a) => a.remoteId.hashCode, ); - albums.addAll(sharedAlbum); - albums.addAll(ownedAlbum); + albums.addAll(allAlbums); changes = await _syncService.syncRemoteAlbumsToDb(albums.toList()); } finally {