Skip to content

Commit

Permalink
according to photo grid setting, let photos group by date in album pa…
Browse files Browse the repository at this point in the history
…ge view on android
  • Loading branch information
ExceptionsOccur authored and ExceptionsOccur committed Jan 17, 2025
1 parent efbc0cb commit c13be84
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions mobile/lib/providers/album/album.provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import 'package:immich_mobile/entities/album.entity.dart';
import 'package:immich_mobile/providers/db.provider.dart';
import 'package:immich_mobile/utils/renderlist_generator.dart';
import 'package:isar/isar.dart';
import '../../services/app_settings.service.dart';
import '../app_settings.provider.dart';

final isRefreshingRemoteAlbumProvider = StateProvider<bool>((ref) => false);

Expand Down Expand Up @@ -150,20 +152,33 @@ final albumWatcher =
}
});

Stream<RenderList> renderListGeneratorWithGroupByDate(
QueryBuilder<Asset, Asset, QAfterSortBy> query,
StreamProviderRef<RenderList> ref,
GroupAssetsBy groupBy,
) {
final settings = ref.watch(appSettingsServiceProvider);
final groupBy =
GroupAssetsBy.values[settings.getSetting(AppSettingsEnum.groupAssetsBy)];
return renderListGeneratorWithGroupBy(query, groupBy);
}

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);
if (album.sortOrder == SortOrder.asc) {
return renderListGeneratorWithGroupBy(
return renderListGeneratorWithGroupByDate(
query.sortByFileCreatedAt(),
ref,
GroupAssetsBy.none,
);
} else if (album.sortOrder == SortOrder.desc) {
return renderListGeneratorWithGroupBy(
return renderListGeneratorWithGroupByDate(
query.sortByFileCreatedAtDesc(),
ref,
GroupAssetsBy.none,
);
}
Expand Down

0 comments on commit c13be84

Please sign in to comment.