mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
fix: persist search page scroll offset between rebuilds (#22733)
fix: persist search scroll between rebuilds Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
parent
6f3cb4f1bb
commit
b3342323de
5 changed files with 37 additions and 16 deletions
|
|
@ -599,9 +599,9 @@ class _SearchResultGrid extends ConsumerWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final searchResult = ref.watch(paginatedSearchProvider);
|
||||
final assets = ref.watch(paginatedSearchProvider.select((s) => s.assets));
|
||||
|
||||
if (searchResult.totalAssets == 0) {
|
||||
if (assets.isEmpty) {
|
||||
return const _SearchEmptyContent();
|
||||
}
|
||||
|
||||
|
|
@ -615,6 +615,7 @@ class _SearchResultGrid extends ConsumerWidget {
|
|||
|
||||
if (metrics.pixels >= metrics.maxScrollExtent && isVerticalScroll && !isBottomSheetNotification) {
|
||||
onScrollEnd();
|
||||
ref.read(paginatedSearchProvider.notifier).setScrollOffset(metrics.maxScrollExtent);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -623,17 +624,18 @@ class _SearchResultGrid extends ConsumerWidget {
|
|||
child: ProviderScope(
|
||||
overrides: [
|
||||
timelineServiceProvider.overrideWith((ref) {
|
||||
final timelineService = ref.watch(timelineFactoryProvider).fromAssets(searchResult.assets);
|
||||
final timelineService = ref.watch(timelineFactoryProvider).fromAssets(assets);
|
||||
ref.onDispose(timelineService.dispose);
|
||||
return timelineService;
|
||||
}),
|
||||
],
|
||||
child: Timeline(
|
||||
key: ValueKey(searchResult.totalAssets),
|
||||
key: ValueKey(assets.length),
|
||||
groupBy: GroupAssetsBy.none,
|
||||
appBar: null,
|
||||
bottomSheet: const GeneralBottomSheet(minChildSize: 0.20),
|
||||
snapToMonth: false,
|
||||
initialScrollOffset: ref.read(paginatedSearchProvider.select((s) => s.scrollOffset)),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue