This commit is contained in:
Alex 2024-09-11 08:46:59 -05:00
parent 701b2be633
commit 4d45e36ea0
No known key found for this signature in database
GPG Key ID: 53CD082B3A5E1082
2 changed files with 28 additions and 3 deletions

View File

@ -27,9 +27,10 @@ class AlbumNotifierV2 extends StateNotifier<List<Album>> {
late final StreamSubscription<List<Album>> _streamSub; late final StreamSubscription<List<Album>> _streamSub;
Future<void> refreshAlbums() async { Future<void> refreshAlbums() async {
await _albumService.refreshDeviceAlbums(); Future.wait([
await _albumService.refreshRemoteAlbums(isShared: false); _albumService.refreshDeviceAlbums(),
await _albumService.refreshRemoteAlbums(isShared: true); _albumService.refreshAllRemoteAlbums(),
]);
} }
Future<void> getDeviceAlbums() { Future<void> getDeviceAlbums() {

View File

@ -173,6 +173,30 @@ class AlbumService {
return changes; return changes;
} }
/// V2
Future<bool> refreshAllRemoteAlbums() async {
final Stopwatch sw = Stopwatch()..start();
try {
final [sharedAlbums, ownedAlbums] = await Future.wait([
_apiService.albumsApi.getAllAlbums(shared: true),
_apiService.albumsApi.getAllAlbums(shared: false),
]);
final List<AlbumResponseDto> allAlbums = [
...sharedAlbums ?? [],
...ownedAlbums ?? [],
];
print("All albums: ${allAlbums.length}");
debugPrint("refreshAllAlbums took ${sw.elapsedMilliseconds}ms");
return true;
} catch (e) {
debugPrint("Error refreshing all albums: $e");
return false;
}
}
Future<Album?> createAlbum( Future<Album?> createAlbum(
String albumName, String albumName,
Iterable<Asset> assets, [ Iterable<Asset> assets, [