From c7a30a3bc2c0aa4acc97bf09ac518811d0330a42 Mon Sep 17 00:00:00 2001 From: vishnukvmd Date: Mon, 19 Dec 2022 12:36:14 +0530 Subject: [PATCH] Reduce sub gallery limits in case of larger thumbnails --- lib/core/constants.dart | 2 ++ lib/ui/huge_listview/lazy_loading_gallery.dart | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/core/constants.dart b/lib/core/constants.dart index 0b5b4b13b..79ca677ba 100644 --- a/lib/core/constants.dart +++ b/lib/core/constants.dart @@ -18,6 +18,8 @@ const int batchSize = 1000; const photoGridSizeDefault = 4; const photoGridSizeMin = 2; const photoGridSizeMax = 6; +const subGalleryLimitDefault = 80; +const subGalleryLimitMin = 40; // used to identify which ente file are available in app cache // todo: 6Jun22: delete old media identifier after 3 months diff --git a/lib/ui/huge_listview/lazy_loading_gallery.dart b/lib/ui/huge_listview/lazy_loading_gallery.dart index 1cb4dec3a..b218701f2 100644 --- a/lib/ui/huge_listview/lazy_loading_gallery.dart +++ b/lib/ui/huge_listview/lazy_loading_gallery.dart @@ -53,7 +53,6 @@ class LazyLoadingGallery extends StatefulWidget { } class _LazyLoadingGalleryState extends State { - static const kSubGalleryItemLimit = 80; static const kRecycleLimit = 400; static const kNumberOfDaysToRenderBeforeAndAfter = 8; @@ -243,13 +242,16 @@ class _LazyLoadingGalleryState extends State { Widget _getGallery() { final List childGalleries = []; - for (int index = 0; index < _files.length; index += kSubGalleryItemLimit) { + final subGalleryItemLimit = widget.photoGirdSize < photoGridSizeDefault + ? subGalleryLimitMin + : subGalleryLimitDefault; + for (int index = 0; index < _files.length; index += subGalleryItemLimit) { childGalleries.add( LazyLoadingGridView( widget.tag, _files.sublist( index, - min(index + kSubGalleryItemLimit, _files.length), + min(index + subGalleryItemLimit, _files.length), ), widget.asyncLoader, widget.selectedFiles,