From c0fe98fe27f257a89b22cf45689bba3f2e7ea608 Mon Sep 17 00:00:00 2001
From: ExceptionsOccur <30021941+ExceptionsOccur@users.noreply.github.com>
Date: Tue, 25 Feb 2025 23:10:08 +0800
Subject: [PATCH] feat(mobile): photos group by date in album page view
 (#16272)

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

* fix: format

---------

Co-authored-by: ExceptionsOccur <yuyu.tao@foxmail.com>
Co-authored-by: Alex <alex.tran1502@gmail.com>
---
 mobile/lib/interfaces/timeline.interface.dart    | 5 ++++-
 mobile/lib/repositories/timeline.repository.dart | 7 +++++--
 mobile/lib/services/timeline.service.dart        | 5 ++++-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/mobile/lib/interfaces/timeline.interface.dart b/mobile/lib/interfaces/timeline.interface.dart
index 2d46dbf688..178cd4a39c 100644
--- a/mobile/lib/interfaces/timeline.interface.dart
+++ b/mobile/lib/interfaces/timeline.interface.dart
@@ -5,7 +5,10 @@ abstract class ITimelineRepository {
   Stream<RenderList> watchArchiveTimeline(int userId);
   Stream<RenderList> watchFavoriteTimeline(int userId);
   Stream<RenderList> watchTrashTimeline(int userId);
-  Stream<RenderList> watchAlbumTimeline(Album album);
+  Stream<RenderList> watchAlbumTimeline(
+    Album album,
+    GroupAssetsBy groupAssetsBy,
+  );
   Stream<RenderList> watchAllVideosTimeline();
 
   Stream<RenderList> watchHomeTimeline(int userId, GroupAssetsBy groupAssetsBy);
diff --git a/mobile/lib/repositories/timeline.repository.dart b/mobile/lib/repositories/timeline.repository.dart
index 8203e5c6e9..7b3f169750 100644
--- a/mobile/lib/repositories/timeline.repository.dart
+++ b/mobile/lib/repositories/timeline.repository.dart
@@ -42,14 +42,17 @@ class TimelineRepository extends DatabaseRepository
   }
 
   @override
-  Stream<RenderList> watchAlbumTimeline(Album album) {
+  Stream<RenderList> watchAlbumTimeline(
+    Album album,
+    GroupAssetsBy groupAssetByOption,
+  ) {
     final query = album.assets.filter().isTrashedEqualTo(false);
     final withSortedOption = switch (album.sortOrder) {
       SortOrder.asc => query.sortByFileCreatedAt(),
       SortOrder.desc => query.sortByFileCreatedAtDesc(),
     };
 
-    return _watchRenderList(withSortedOption, GroupAssetsBy.none);
+    return _watchRenderList(withSortedOption, groupAssetByOption);
   }
 
   @override
diff --git a/mobile/lib/services/timeline.service.dart b/mobile/lib/services/timeline.service.dart
index e435ba72c9..513b1b1ab2 100644
--- a/mobile/lib/services/timeline.service.dart
+++ b/mobile/lib/services/timeline.service.dart
@@ -50,7 +50,10 @@ class TimelineService {
   }
 
   Stream<RenderList> watchAlbumTimeline(Album album) async* {
-    yield* _timelineRepository.watchAlbumTimeline(album);
+    yield* _timelineRepository.watchAlbumTimeline(
+      album,
+      _getGroupByOption(),
+    );
   }
 
   Stream<RenderList> watchTrashTimeline() async* {