π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Limit gallery refresh deferral to covered routes
ashil-pilot3af6e58f9166
diff --git a/mobile/apps/photos/lib/ui/tabs/home_widget.dart b/mobile/apps/photos/lib/ui/tabs/home_widget.dartindex 281e578dae..0b5c0fd147 100644--- a/mobile/apps/photos/lib/ui/tabs/home_widget.dart+++ b/mobile/apps/photos/lib/ui/tabs/home_widget.dart@@ -82,7 +82,6 @@ import "package:photos/ui/viewer/actions/file_viewer.dart";import "package:photos/ui/viewer/file/detail_page.dart";import "package:photos/ui/viewer/gallery/collection_page.dart";import "package:photos/ui/viewer/gallery/shared_public_collection_page.dart";-import "package:photos/ui/viewer/gallery/state/gallery_visibility_scope.dart";import "package:photos/ui/viewer/search_tab/search_tab.dart";import "package:photos/utils/collection_util.dart";import "package:photos/utils/dialog_util.dart";@@ -1218,10 +1217,7 @@ class _HomeWidgetState extends State<HomeWidget> {Widget _buildTabHeroMode(int tabIndex, int selectedTabIndex, Widget child) {return ClipRect(- child: GalleryVisibilityScope(- visible: tabIndex == selectedTabIndex,- child: HeroMode(enabled: tabIndex == selectedTabIndex, child: child),- ),+ child: HeroMode(enabled: tabIndex == selectedTabIndex, child: child),);}diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dartindex a5fe903dee..2c8682784e 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart@@ -37,7 +37,6 @@ import "package:photos/ui/viewer/gallery/state/boundary_reporter_mixin.dart";import "package:photos/ui/viewer/gallery/state/gallery_boundaries_provider.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/gallery_visibility_scope.dart";import "package:photos/ui/viewer/gallery/state/inherited_search_filter_data.dart";import "package:photos/ui/viewer/gallery/swipe_selection_wrapper.dart";import "package:photos/ui/viewer/gallery/swipe_to_select_helper.dart";@@ -169,7 +168,6 @@ class GalleryState extends State<Gallery> {int _layoutChangeGeneration = 0;bool _committingGridZoom = false;bool _isGalleryVisible = false;- bool _isGalleryTabVisible = true;ModalRoute<dynamic>? _layoutPreviewRoute;bool _needsLayoutRefresh = false;int _activeFileLoads = 0;@@ -369,10 +367,8 @@ class GalleryState extends State<Gallery> {@overridevoid didChangeDependencies() {super.didChangeDependencies();- final isRouteCurrent = ModalRoute.isCurrentOf(context) ?? true;- _isGalleryTabVisible = GalleryVisibilityScope.isVisibleOf(context);final wasVisible = _isGalleryVisible;- _isGalleryVisible = isRouteCurrent && _isGalleryTabVisible;+ _isGalleryVisible = ModalRoute.isCurrentOf(context) ?? true;if (wasVisible && !_isGalleryVisible) {++_layoutChangeGeneration;if (groupHeaderExtent == null) _needsLayoutRefresh = true;@@ -395,8 +391,7 @@ class GalleryState extends State<Gallery> {}bool get _canRefreshGalleryLayout =>- _isGalleryVisible ||- (_isGalleryTabVisible && (_layoutPreviewRoute?.isCurrent ?? false));+ _isGalleryVisible || (_layoutPreviewRoute?.isCurrent ?? false);void setLayoutPreviewVisibility(ModalRoute<dynamic> route, bool visible) {if (!mounted) return;diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/state/gallery_visibility_scope.dart b/mobile/apps/photos/lib/ui/viewer/gallery/state/gallery_visibility_scope.dartdeleted file mode 100644index d554f03511..0000000000--- a/mobile/apps/photos/lib/ui/viewer/gallery/state/gallery_visibility_scope.dart+++ /dev/null@@ -1,21 +0,0 @@-import "package:flutter/widgets.dart";--class GalleryVisibilityScope extends InheritedWidget {- const GalleryVisibilityScope({- required this.visible,- required super.child,- super.key,- });-- final bool visible;-- static bool isVisibleOf(BuildContext context) =>- context- .dependOnInheritedWidgetOfExactType<GalleryVisibilityScope>()- ?.visible ??- true;-- @override- bool updateShouldNotify(GalleryVisibilityScope oldWidget) =>- visible != oldWidget.visible;-}diff --git a/mobile/apps/photos/test/ui/viewer/gallery/gallery_layout_changed_event_test.dart b/mobile/apps/photos/test/ui/viewer/gallery/gallery_layout_changed_event_test.dartindex 8806925bbf..94b8ba524e 100644--- a/mobile/apps/photos/test/ui/viewer/gallery/gallery_layout_changed_event_test.dart+++ b/mobile/apps/photos/test/ui/viewer/gallery/gallery_layout_changed_event_test.dart@@ -29,7 +29,6 @@ import "package:photos/ui/viewer/gallery/gallery_grid_zoom.dart";import "package:photos/ui/viewer/gallery/layout_settings.dart";import "package:photos/ui/viewer/gallery/state/gallery_boundaries_provider.dart";import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";-import "package:photos/ui/viewer/gallery/state/gallery_visibility_scope.dart";import "package:shared_preferences/shared_preferences.dart";void main() {@@ -816,80 +815,6 @@ void main() {await tester.pump(const Duration(milliseconds: 100));});- testWidgets("inactive tabs load files without building their grids", (- tester,- ) async {- await localSettings.setPhotoGridSize(4);- final visible = ValueNotifier(false);- addTearDown(visible.dispose);- final galleryKey = GlobalKey<GalleryState>();- final files = List<EnteFile>.generate(100, _justifiedTestFile);- final initialLoad = Completer<FileLoadResult>();- final loadedLimits = <int?>[];- await tester.pumpWidget(- MaterialApp(- theme: lightThemeData,- home: ValueListenableBuilder(- valueListenable: visible,- builder: (_, isVisible, child) =>- GalleryVisibilityScope(visible: isVisible, child: child!),- child: _galleryHost(- Gallery(- key: galleryKey,- asyncLoader: (start, end, {limit, asc}) async {- loadedLimits.add(limit);- return loadedLimits.length == 1- ? initialLoad.future- : FileLoadResult(files, false);- },- tagPrefix: "inactive_tab_",- enableFileGrouping: false,- showSelectAll: false,- ),- ),- ),- ),- );- await tester.pumpAndSettle();- expect(galleryKey.currentState!.galleryGroups, isNull);- expect(loadedLimits, [GalleryState.kInitialLoadLimit]);- await localSettings.setPhotoGridSize(6);- Bus.instance.fire(GalleryLayoutChangedEvent());- await tester.pumpAndSettle();- expect(galleryKey.currentState!.galleryGroups, isNull);- expect(loadedLimits, [GalleryState.kInitialLoadLimit]);-- initialLoad.complete(FileLoadResult(files.take(10).toList(), true));- await tester.pumpAndSettle();- expect(galleryKey.currentState!.galleryGroups, isNull);- expect(loadedLimits, [GalleryState.kInitialLoadLimit, null]);- await localSettings.setGalleryLayoutType(GalleryLayoutType.justified);- Bus.instance.fire(GalleryLayoutChangedEvent());- await tester.pumpAndSettle();- expect(galleryKey.currentState!.galleryGroups, isNull);-- visible.value = true;- await tester.pumpAndSettle();- expect(loadedLimits, [GalleryState.kInitialLoadLimit, null]);- expect(galleryKey.currentState!.galleryGroups!.allFiles, files);- expect(- galleryKey.currentState!.galleryGroups!.layoutType,- GalleryLayoutType.justified,- );-- visible.value = false;- await tester.pump();- await localSettings.setGalleryLayoutType(GalleryLayoutType.grid);- Bus.instance.fire(GalleryLayoutChangedEvent());- await tester.pump();- visible.value = true;- await tester.pumpAndSettle();- expect(galleryKey.currentState!.galleryGroups!.crossAxisCount, 6);- expect(loadedLimits, [GalleryState.kInitialLoadLimit, null]);- await tester.pumpWidget(const SizedBox.shrink());- await tester.pump(const Duration(milliseconds: 100));- });-testWidgets("a deep layout change preserves partial-row progress", (tester,) async {