π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Fixes for local gallery (#9548)
Laurens Priemb48f7f29fb6a
diff --git a/mobile/apps/photos/lib/services/search_service.dart b/mobile/apps/photos/lib/services/search_service.dartindex ec2f6c73ad..9565711c9d 100644--- a/mobile/apps/photos/lib/services/search_service.dart+++ b/mobile/apps/photos/lib/services/search_service.dart@@ -70,6 +70,7 @@ class SearchService {Future<List<EnteFile>>? _cachedFilesForSearch;Future<List<EnteFile>>? _cachedFilesForHierarchicalSearch;Future<List<EnteFile>>? _cachedFilesForGenericGallery;+ Future<List<EnteFile>>? _cachedFilesForOfflineGallery;Future<List<EnteFile>>? _cachedHiddenFilesFuture;final _logger = Logger((SearchService).toString());final _collectionService = CollectionsService.instance;@@ -90,6 +91,7 @@ class SearchService {_cachedFilesForSearch = null;_cachedFilesForHierarchicalSearch = null;_cachedFilesForGenericGallery = null;+ _cachedFilesForOfflineGallery = null;_cachedHiddenFilesFuture = null;});}@@ -150,9 +152,16 @@ class SearchService {return _cachedFilesForHierarchicalSearch!;}- Future<List<EnteFile>> getAllFilesForGenericGallery() async {- if (_cachedFilesFuture != null && _cachedFilesForGenericGallery != null) {- return _cachedFilesForGenericGallery!;+ Future<List<EnteFile>> getAllFilesForGenericGallery({+ bool onlyUploadedFiles = true,+ }) async {+ if (_cachedFilesFuture != null) {+ if (onlyUploadedFiles && _cachedFilesForGenericGallery != null) {+ return _cachedFilesForGenericGallery!;+ }+ if (!onlyUploadedFiles && _cachedFilesForOfflineGallery != null) {+ return _cachedFilesForOfflineGallery!;+ }}if (_cachedFilesFuture == null) {@@ -163,17 +172,23 @@ class SearchService {);}- _cachedFilesForGenericGallery = _cachedFilesFuture!.then((files) {+ final filteredFiles = _cachedFilesFuture!.then((files) {return applyDBFilters(files,DBFilterOptions(dedupeUploadID: true,- onlyUploadedFiles: true,+ onlyUploadedFiles: onlyUploadedFiles,),);});- return _cachedFilesForGenericGallery!;+ if (onlyUploadedFiles) {+ _cachedFilesForGenericGallery = filteredFiles;+ return _cachedFilesForGenericGallery!;+ } else {+ _cachedFilesForOfflineGallery = filteredFiles;+ return _cachedFilesForOfflineGallery!;+ }}Future<List<EnteFile>> getHiddenFiles() async {@@ -193,6 +208,7 @@ class SearchService {_cachedFilesForSearch = null;_cachedFilesForHierarchicalSearch = null;_cachedFilesForGenericGallery = null;+ _cachedFilesForOfflineGallery = null;_cachedHiddenFilesFuture = null;unawaited(memoriesCacheService.clearMemoriesCache());}diff --git a/mobile/apps/photos/lib/ui/components/banners/offline_settings_banner.dart b/mobile/apps/photos/lib/ui/components/banners/offline_settings_banner.dartindex 7bab7d8885..2a1a1ccff7 100644--- a/mobile/apps/photos/lib/ui/components/banners/offline_settings_banner.dart+++ b/mobile/apps/photos/lib/ui/components/banners/offline_settings_banner.dart@@ -44,7 +44,7 @@ class _OfflineSettingsBannerState extends State<OfflineSettingsBanner> {return GestureDetector(onTap: widget.onGetStarted,child: Container(- height: 175,+ constraints: const BoxConstraints(minHeight: 190),clipBehavior: Clip.hardEdge,decoration: BoxDecoration(borderRadius: BorderRadius.circular(16),@@ -73,12 +73,9 @@ class _OfflineSettingsBannerState extends State<OfflineSettingsBanner> {crossAxisAlignment: CrossAxisAlignment.start,children: [Expanded(- child: ConstrainedBox(- constraints: const BoxConstraints(maxWidth: 235),- child: Text(- l10n.offlineSettingsBannerTitle,- style: titleStyle,- ),+ child: Text(+ l10n.offlineSettingsBannerTitle,+ style: titleStyle,),),GestureDetector(@@ -112,27 +109,24 @@ class _OfflineSettingsBannerState extends State<OfflineSettingsBanner> {),),),+ const SizedBox(height: 40),+ BannerActionButton(+ label: l10n.getStarted,+ onTap: widget.onGetStarted,+ variant: BannerActionButtonVariant.primary,+ stickTagToLightTheme: true,+ showTag: true,+ ),],),),- Positioned(- left: 16,- bottom: 16,- child: BannerActionButton(- label: l10n.getStarted,- onTap: widget.onGetStarted,- variant: BannerActionButtonVariant.primary,- stickTagToLightTheme: true,- showTag: true,- ),- ),Positioned(right: 16,bottom: 0,child: IgnorePointer(child: Image.asset("assets/ducky_settings.png",- height: 100,+ height: 110,fit: BoxFit.contain,),),diff --git a/mobile/apps/photos/lib/ui/settings/gallery_settings_screen.dart b/mobile/apps/photos/lib/ui/settings/gallery_settings_screen.dartindex cda8b73de1..4561a5bf19 100644--- a/mobile/apps/photos/lib/ui/settings/gallery_settings_screen.dart+++ b/mobile/apps/photos/lib/ui/settings/gallery_settings_screen.dart@@ -106,7 +106,8 @@ class _GallerySettingsScreenState extends State<GallerySettingsScreen> {});},),- if (!widget.fromGalleryLayoutSettingsCTA) ...[+ if (!widget.fromGalleryLayoutSettingsCTA &&+ !isOfflineMode) ...[const SizedBox(height: 8),MenuItemWidgetNew(title: AppLocalizations.of(context)diff --git a/mobile/apps/photos/lib/ui/settings/search/settings_search_registry.dart b/mobile/apps/photos/lib/ui/settings/search/settings_search_registry.dartindex c7b5d6e988..564c46e4b2 100644--- a/mobile/apps/photos/lib/ui/settings/search/settings_search_registry.dart+++ b/mobile/apps/photos/lib/ui/settings/search/settings_search_registry.dart@@ -365,19 +365,21 @@ class SettingsSearchRegistry {),);- items.add(- SettingsSearchItem(- title: l10n.hideSharedItemsFromHomeGallery,- subtitle: l10n.gallery,- sectionPath: "${l10n.appearance} > ${l10n.gallery}",- icon: HugeIcons.strokeRoundedImage01,- routeBuilder: (_) => const GallerySettingsScreen(- fromGalleryLayoutSettingsCTA: false,+ if (!isOffline) {+ items.add(+ SettingsSearchItem(+ title: l10n.hideSharedItemsFromHomeGallery,+ subtitle: l10n.gallery,+ sectionPath: "${l10n.appearance} > ${l10n.gallery}",+ icon: HugeIcons.strokeRoundedImage01,+ routeBuilder: (_) => const GallerySettingsScreen(+ fromGalleryLayoutSettingsCTA: false,+ ),+ isSubPage: true,+ keywords: ["shared", "hide", "home gallery"],),- isSubPage: true,- keywords: ["shared", "hide", "home gallery"],- ),- );+ );+ }// Machine Learning settingsif (hasLoggedIn || isOffline) {diff --git a/mobile/apps/photos/lib/ui/tabs/home_widget.dart b/mobile/apps/photos/lib/ui/tabs/home_widget.dartindex 0d287b14c7..b2566b1e70 100644--- a/mobile/apps/photos/lib/ui/tabs/home_widget.dart+++ b/mobile/apps/photos/lib/ui/tabs/home_widget.dart@@ -233,6 +233,13 @@ class _HomeWidgetState extends State<HomeWidget> {if (mounted) {setState(() {});syncWidget();+ if (!NotificationService.instance.hasGrantedPermissions() &&+ isOfflineMode &&+ !Configuration.instance.hasConfiguredAccount()) {+ Future.delayed(const Duration(seconds: 2), () {+ NotificationService.instance.requestPermissions().ignore();+ });+ }}},);diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/jump_to_date_gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/jump_to_date_gallery.dartindex 117afbe00e..cd4c02e2f0 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/jump_to_date_gallery.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/jump_to_date_gallery.dart@@ -1,6 +1,7 @@import "dart:async";import 'package:flutter/material.dart';+import "package:photos/core/configuration.dart";import 'package:photos/core/event_bus.dart';import 'package:photos/events/files_updated_event.dart';import 'package:photos/events/local_photos_updated_event.dart';@@ -8,6 +9,7 @@ import 'package:photos/models/file/file.dart';import 'package:photos/models/file_load_result.dart';import 'package:photos/models/gallery_type.dart';import 'package:photos/models/selected_files.dart';+import "package:photos/service_locator.dart" show isOfflineMode;import 'package:photos/services/search_service.dart';import "package:photos/theme/ente_theme.dart";import 'package:photos/ui/common/loading_widget.dart';@@ -71,8 +73,11 @@ class _JumpToDateGalleryState extends State<JumpToDateGallery> {Future<void> _loadFiles() async {final startTime = DateTime.now();- final allFiles =- await SearchService.instance.getAllFilesForGenericGallery();+ final onlyUploadedFiles =+ !(isOfflineMode && !Configuration.instance.hasConfiguredAccount());+ final allFiles = await SearchService.instance.getAllFilesForGenericGallery(+ onlyUploadedFiles: onlyUploadedFiles,+ );// Ensure minimum loading duration to mask Gallery initialization jankfinal elapsed = DateTime.now().difference(startTime).inMilliseconds;