Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mobile): photos group by date in album page view #15329

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can fetch the current user preferences and pass it in here, so you don't need to create a new renderListGenerator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar enough with the code. I'll try to improve it later

);
} else if (album.sortOrder == SortOrder.desc) {
return renderListGeneratorWithGroupBy(
return renderListGeneratorWithGroupByDate(
query.sortByFileCreatedAtDesc(),
ref,
GroupAssetsBy.none,
);
}
Expand Down
Loading