0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-02-18 01:24:26 -05:00

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.
This commit is contained in:
Tom graham 2025-01-08 15:45:30 +11:00
parent a42911b290
commit 979ce90abf

View file

@ -157,7 +157,7 @@ class AlbumService {
return result; 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 /// updates the local database and returns `true` if there were any changes
Future<bool> refreshRemoteAlbums() async { Future<bool> refreshRemoteAlbums() async {
if (!_remoteCompleter.isCompleted) { if (!_remoteCompleter.isCompleted) {
@ -169,18 +169,14 @@ class AlbumService {
bool changes = false; bool changes = false;
try { try {
await _userService.refreshUsers(); await _userService.refreshUsers();
final (sharedAlbum, ownedAlbum) = await ( final allAlbums = await _albumApiRepository.getAll();
_albumApiRepository.getAll(shared: true),
_albumApiRepository.getAll(shared: null)
).wait;
final albums = HashSet<Album>( final albums = HashSet<Album>(
equals: (a, b) => a.remoteId == b.remoteId, equals: (a, b) => a.remoteId == b.remoteId,
hashCode: (a) => a.remoteId.hashCode, hashCode: (a) => a.remoteId.hashCode,
); );
albums.addAll(sharedAlbum); albums.addAll(allAlbums);
albums.addAll(ownedAlbum);
changes = await _syncService.syncRemoteAlbumsToDb(albums.toList()); changes = await _syncService.syncRemoteAlbumsToDb(albums.toList());
} finally { } finally {