mirror of
https://github.com/immich-app/immich.git
synced 2024-09-21 02:27:25 +00:00
wip
This commit is contained in:
parent
e69bcf3f70
commit
4c9a7a7ed5
@ -8,7 +8,6 @@ import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||
import 'package:immich_mobile/extensions/theme_extensions.dart';
|
||||
import 'package:immich_mobile/main.dart';
|
||||
import 'package:immich_mobile/pages/common/large_leading_tile.dart';
|
||||
import 'package:immich_mobile/providers/album/album_sort_by_options.provider.dart';
|
||||
import 'package:immich_mobile/providers/album/albumv2.provider.dart';
|
||||
@ -78,7 +77,11 @@ class AlbumsCollectionPage extends HookConsumerWidget {
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: showImmichAppbar ? null : Text('albums'.tr()),
|
||||
title: showImmichAppbar
|
||||
? null
|
||||
: Text(
|
||||
"${'albums'.tr()} ${albums.length}",
|
||||
),
|
||||
bottom: showImmichAppbar
|
||||
? const PreferredSize(
|
||||
preferredSize: Size.fromHeight(0),
|
||||
|
@ -27,10 +27,13 @@ class AlbumNotifierV2 extends StateNotifier<List<Album>> {
|
||||
late final StreamSubscription<List<Album>> _streamSub;
|
||||
|
||||
Future<void> refreshAlbums() async {
|
||||
Future.wait([
|
||||
_albumService.refreshDeviceAlbums(),
|
||||
_albumService.refreshAllRemoteAlbums(),
|
||||
]);
|
||||
// Future.wait([
|
||||
// _albumService.refreshDeviceAlbums(),
|
||||
// _albumService.refreshAllRemoteAlbums(),
|
||||
// ]);
|
||||
await _albumService.refreshDeviceAlbums();
|
||||
await _albumService.refreshRemoteAlbums(isShared: false);
|
||||
await _albumService.refreshRemoteAlbums(isShared: true);
|
||||
}
|
||||
|
||||
Future<void> getDeviceAlbums() {
|
||||
|
@ -175,26 +175,45 @@ class AlbumService {
|
||||
|
||||
/// V2
|
||||
Future<bool> refreshAllRemoteAlbums() async {
|
||||
if (!_remoteCompleter.isCompleted) {
|
||||
// guard against concurrent calls
|
||||
return _remoteCompleter.future;
|
||||
}
|
||||
_remoteCompleter = Completer();
|
||||
final Stopwatch sw = Stopwatch()..start();
|
||||
bool changes = false;
|
||||
try {
|
||||
final [sharedAlbums, ownedAlbums] = await Future.wait([
|
||||
final albumList = await Future.wait([
|
||||
_apiService.albumsApi.getAllAlbums(shared: true),
|
||||
_apiService.albumsApi.getAllAlbums(shared: false),
|
||||
]);
|
||||
|
||||
final List<AlbumResponseDto> allAlbums = [
|
||||
...sharedAlbums ?? [],
|
||||
...ownedAlbums ?? [],
|
||||
];
|
||||
// for (int i = 0; i < albumList.length; i++) {
|
||||
// final albums = albumList[i];
|
||||
// final isShared = i == 1;
|
||||
// if (albums != null) {
|
||||
// final hasChange = await _syncService.syncRemoteAlbumsToDb(
|
||||
// albums,
|
||||
// isShared: isShared,
|
||||
// loadDetails: (dto) async => dto.assetCount == dto.assets.length
|
||||
// ? dto
|
||||
// : (await _apiService.albumsApi.getAlbumInfo(dto.id)) ?? dto,
|
||||
// );
|
||||
|
||||
print("All albums: ${allAlbums.length}");
|
||||
|
||||
debugPrint("refreshAllAlbums took ${sw.elapsedMilliseconds}ms");
|
||||
return true;
|
||||
// if (hasChange) {
|
||||
// changes = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
} catch (e) {
|
||||
debugPrint("Error refreshing all albums: $e");
|
||||
return false;
|
||||
} finally {
|
||||
_remoteCompleter.complete(changes);
|
||||
}
|
||||
|
||||
debugPrint("refreshAllRemoteAlbums took ${sw.elapsedMilliseconds}ms");
|
||||
return changes;
|
||||
}
|
||||
|
||||
Future<Album?> createAlbum(
|
||||
|
Loading…
Reference in New Issue
Block a user