mirror of
https://github.com/immich-app/immich.git
synced 2025-07-09 03:06:56 -04: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:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/theme_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/pages/common/large_leading_tile.dart';
|
||||||
import 'package:immich_mobile/providers/album/album_sort_by_options.provider.dart';
|
import 'package:immich_mobile/providers/album/album_sort_by_options.provider.dart';
|
||||||
import 'package:immich_mobile/providers/album/albumv2.provider.dart';
|
import 'package:immich_mobile/providers/album/albumv2.provider.dart';
|
||||||
@ -78,7 +77,11 @@ class AlbumsCollectionPage extends HookConsumerWidget {
|
|||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: showImmichAppbar ? null : Text('albums'.tr()),
|
title: showImmichAppbar
|
||||||
|
? null
|
||||||
|
: Text(
|
||||||
|
"${'albums'.tr()} ${albums.length}",
|
||||||
|
),
|
||||||
bottom: showImmichAppbar
|
bottom: showImmichAppbar
|
||||||
? const PreferredSize(
|
? const PreferredSize(
|
||||||
preferredSize: Size.fromHeight(0),
|
preferredSize: Size.fromHeight(0),
|
||||||
|
@ -27,10 +27,13 @@ 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 {
|
||||||
Future.wait([
|
// Future.wait([
|
||||||
_albumService.refreshDeviceAlbums(),
|
// _albumService.refreshDeviceAlbums(),
|
||||||
_albumService.refreshAllRemoteAlbums(),
|
// _albumService.refreshAllRemoteAlbums(),
|
||||||
]);
|
// ]);
|
||||||
|
await _albumService.refreshDeviceAlbums();
|
||||||
|
await _albumService.refreshRemoteAlbums(isShared: false);
|
||||||
|
await _albumService.refreshRemoteAlbums(isShared: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getDeviceAlbums() {
|
Future<void> getDeviceAlbums() {
|
||||||
|
@ -175,26 +175,45 @@ class AlbumService {
|
|||||||
|
|
||||||
/// V2
|
/// V2
|
||||||
Future<bool> refreshAllRemoteAlbums() async {
|
Future<bool> refreshAllRemoteAlbums() async {
|
||||||
|
if (!_remoteCompleter.isCompleted) {
|
||||||
|
// guard against concurrent calls
|
||||||
|
return _remoteCompleter.future;
|
||||||
|
}
|
||||||
|
_remoteCompleter = Completer();
|
||||||
final Stopwatch sw = Stopwatch()..start();
|
final Stopwatch sw = Stopwatch()..start();
|
||||||
|
bool changes = false;
|
||||||
try {
|
try {
|
||||||
final [sharedAlbums, ownedAlbums] = await Future.wait([
|
final albumList = await Future.wait([
|
||||||
_apiService.albumsApi.getAllAlbums(shared: true),
|
_apiService.albumsApi.getAllAlbums(shared: true),
|
||||||
_apiService.albumsApi.getAllAlbums(shared: false),
|
_apiService.albumsApi.getAllAlbums(shared: false),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
final List<AlbumResponseDto> allAlbums = [
|
// for (int i = 0; i < albumList.length; i++) {
|
||||||
...sharedAlbums ?? [],
|
// final albums = albumList[i];
|
||||||
...ownedAlbums ?? [],
|
// 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}");
|
// if (hasChange) {
|
||||||
|
// changes = true;
|
||||||
debugPrint("refreshAllAlbums took ${sw.elapsedMilliseconds}ms");
|
// }
|
||||||
return true;
|
// }
|
||||||
|
// }
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint("Error refreshing all albums: $e");
|
debugPrint("Error refreshing all albums: $e");
|
||||||
return false;
|
return false;
|
||||||
|
} finally {
|
||||||
|
_remoteCompleter.complete(changes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debugPrint("refreshAllRemoteAlbums took ${sw.elapsedMilliseconds}ms");
|
||||||
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Album?> createAlbum(
|
Future<Album?> createAlbum(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user