Skip to content

armgit / ente

Public Imported from GitHub
0

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

Avoid redundant setState call

ashilkn03c116c2bada
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
index 6b77429441..18dcdbe681 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
@@ -627,6 +627,8 @@ class _PinnedGroupHeaderState extends State<PinnedGroupHeader> {
widget
.getSectionedListSliverRenderBoxYOffsetRelativeToStackRenderBox()!;
if (normalizedScrollOffset < 0) {
+ // No change in group ID, no need to call setState
+ if (currentGroupId == null) return;
currentGroupId = null;
} else {
final groupScrollOffsets = widget.galleryGroups.groupScrollOffsets;
@@ -659,6 +661,12 @@ class _PinnedGroupHeaderState extends State<PinnedGroupHeader> {
high = mid - 1;
}
}
+ if (currentGroupId ==
+ widget.galleryGroups
+ .scrollOffsetToGroupIdMap[groupScrollOffsets[floorIndex]]) {
+ // No change in group ID, no need to call setState
+ return;
+ }
currentGroupId = widget.galleryGroups
.scrollOffsetToGroupIdMap[groupScrollOffsets[floorIndex]];
}