Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Different cache extents for different photoGridSizes

ashilkn769adb75c57c
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
index 1d8f57c0ee..d8269595c6 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
@@ -29,6 +29,7 @@ import "package:photos/ui/viewer/gallery/scrollbar/custom_scroll_bar.dart";
import "package:photos/ui/viewer/gallery/state/gallery_context_state.dart";
import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
import "package:photos/ui/viewer/gallery/state/inherited_search_filter_data.dart";
+import "package:photos/utils/gallery_util.dart";
import "package:photos/utils/hierarchical_search_util.dart";
import "package:photos/utils/misc_util.dart";
import "package:photos/utils/standalone/date_time.dart";
@@ -600,7 +601,7 @@ class GalleryState extends State<Gallery> {
? const NeverScrollableScrollPhysics()
: const ExponentialBouncingScrollPhysics(),
controller: _scrollController,
- cacheExtent: 1000,
+ cacheExtent: galleryCacheExtent,
slivers: [
SliverToBoxAdapter(
child: SizeChangedLayoutNotifier(
diff --git a/mobile/apps/photos/lib/utils/gallery_util.dart b/mobile/apps/photos/lib/utils/gallery_util.dart
new file mode 100644
index 0000000000..8ed529d390
--- /dev/null
+++ b/mobile/apps/photos/lib/utils/gallery_util.dart
@@ -0,0 +1,18 @@
+import "package:photos/service_locator.dart";
+
+double get galleryCacheExtent {
+ final int photoGridSize = localSettings.getPhotoGridSize();
+ switch (photoGridSize) {
+ case 2:
+ case 3:
+ return 1000;
+ case 4:
+ return 850;
+ case 5:
+ return 600;
+ case 6:
+ return 300;
+ default:
+ throw StateError('Invalid photo grid size configuration: $photoGridSize');
+ }
+}