mirror of
https://github.com/immich-app/immich.git
synced 2026-03-09 19:57:41 +03:00
feat(album): album view sort order (#14648)
* feat(mobile): album view sort order * feat: add error message * refactor(mobile): album page (#14659) * refactor album page * update lint rule * const record * fix: updating sort order when pull to refresh --------- Co-authored-by: Alex <alex.tran1502@gmail.com> * Move sort toggle button to bottom sheet menu * chore: revert multiselectgrid loading status * chore: revert multiselectgrid loading status --------- Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/constants/enums.dart';
|
||||
import 'package:immich_mobile/entities/user.entity.dart';
|
||||
import 'package:immich_mobile/models/albums/album_search.model.dart';
|
||||
import 'package:immich_mobile/services/album.service.dart';
|
||||
@@ -106,6 +107,13 @@ class AlbumNotifier extends StateNotifier<List<Album>> {
|
||||
return _albumService.setActivityStatus(album, enabled);
|
||||
}
|
||||
|
||||
Future<Album?> toggleSortOrder(Album album) {
|
||||
final order =
|
||||
album.sortOrder == SortOrder.asc ? SortOrder.desc : SortOrder.asc;
|
||||
|
||||
return _albumService.updateSortOrder(album, order);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_streamSub.cancel();
|
||||
@@ -135,11 +143,22 @@ final albumWatcher =
|
||||
final albumRenderlistProvider =
|
||||
StreamProvider.autoDispose.family<RenderList, int>((ref, albumId) {
|
||||
final album = ref.watch(albumWatcher(albumId)).value;
|
||||
|
||||
if (album != null) {
|
||||
final query =
|
||||
album.assets.filter().isTrashedEqualTo(false).sortByFileCreatedAtDesc();
|
||||
return renderListGeneratorWithGroupBy(query, GroupAssetsBy.none);
|
||||
final query = album.assets.filter().isTrashedEqualTo(false);
|
||||
if (album.sortOrder == SortOrder.asc) {
|
||||
return renderListGeneratorWithGroupBy(
|
||||
query.sortByFileCreatedAt(),
|
||||
GroupAssetsBy.none,
|
||||
);
|
||||
} else if (album.sortOrder == SortOrder.desc) {
|
||||
return renderListGeneratorWithGroupBy(
|
||||
query.sortByFileCreatedAtDesc(),
|
||||
GroupAssetsBy.none,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return const Stream.empty();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user