Browse Source

Reduce sub gallery limits in case of larger thumbnails

vishnukvmd 2 years ago
parent
commit
c7a30a3bc2
2 changed files with 7 additions and 3 deletions
  1. 2 0
      lib/core/constants.dart
  2. 5 3
      lib/ui/huge_listview/lazy_loading_gallery.dart

+ 2 - 0
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

+ 5 - 3
lib/ui/huge_listview/lazy_loading_gallery.dart

@@ -53,7 +53,6 @@ class LazyLoadingGallery extends StatefulWidget {
 }
 
 class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
-  static const kSubGalleryItemLimit = 80;
   static const kRecycleLimit = 400;
   static const kNumberOfDaysToRenderBeforeAndAfter = 8;
 
@@ -243,13 +242,16 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
 
   Widget _getGallery() {
     final List<Widget> 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,