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;
}
/// 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<bool> 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<Album>(
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 {