π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
chore: nit fixes
Prateek Sunal3756a56776ce
diff --git a/mobile/apps/photos/lib/app.dart b/mobile/apps/photos/lib/app.dartindex a6c90a84d7..64a2700c7a 100644--- a/mobile/apps/photos/lib/app.dart+++ b/mobile/apps/photos/lib/app.dart@@ -20,7 +20,6 @@ import 'package:photos/services/app_lifecycle_service.dart';import "package:photos/services/home_widget_service.dart";import "package:photos/services/memory_home_widget_service.dart";import "package:photos/services/people_home_widget_service.dart";-import "package:photos/services/smart_albums_service.dart";import 'package:photos/services/sync/sync_service.dart';import 'package:photos/ui/tabs/home_widget.dart';import "package:photos/ui/viewer/actions/file_viewer.dart";@@ -77,7 +76,7 @@ class _EnteAppState extends State<EnteApp> with WidgetsBindingObserver {_changeCallbackDebouncer.run(() async {unawaited(PeopleHomeWidgetService.instance.checkPeopleChanged());- unawaited(SmartAlbumsService.instance.syncSmartAlbums());+ unawaited(smartAlbumsService.syncSmartAlbums());},);},diff --git a/mobile/apps/photos/lib/db/files_db.dart b/mobile/apps/photos/lib/db/files_db.dartindex e2faeee4f5..f8900f8912 100644--- a/mobile/apps/photos/lib/db/files_db.dart+++ b/mobile/apps/photos/lib/db/files_db.dart@@ -1479,7 +1479,6 @@ class FilesDB with SqlDbBase {final inParam = ids.map((id) => "'$id'").join(',');final db = await instance.sqliteAsyncDB;-final results = await db.getAll('SELECT * FROM $filesTable WHERE $columnUploadedFileID IN ($inParam) ORDER BY $columnCreationTime $order',);diff --git a/mobile/apps/photos/lib/models/collection/smart_album_config.dart b/mobile/apps/photos/lib/models/collection/smart_album_config.dartindex 3ab36d21ee..2a90a31fd2 100644--- a/mobile/apps/photos/lib/models/collection/smart_album_config.dart+++ b/mobile/apps/photos/lib/models/collection/smart_album_config.dart@@ -2,7 +2,7 @@ typedef PersonInfo = ({int updatedAt, Set<int> addedFiles});class SmartAlbumConfig {// A nullable remote ID for syncing purposes- final String? remoteId;+ final String? id;final int collectionId;// person ids@@ -12,14 +12,14 @@ class SmartAlbumConfig {final int updatedAt;SmartAlbumConfig({- this.remoteId,+ this.id,required this.collectionId,required this.personIDs,required this.infoMap,this.updatedAt = 0,});- Future<SmartAlbumConfig> getUpdatedConfig(Set<String> newPersonsIds) async {+ SmartAlbumConfig getUpdatedConfig(Set<String> newPersonsIds) {final toAdd = newPersonsIds.difference(personIDs);final toRemove = personIDs.difference(newPersonsIds);final newInfoMap = Map<String, PersonInfo>.from(infoMap);@@ -35,7 +35,7 @@ class SmartAlbumConfig {}return SmartAlbumConfig(- remoteId: remoteId,+ id: id,collectionId: collectionId,personIDs: newPersonsIds,infoMap: newInfoMap,@@ -58,7 +58,7 @@ class SmartAlbumConfig {addedFiles: newInfoMap[personId]!.addedFiles.union(fileId),);return SmartAlbumConfig(- remoteId: remoteId,+ id: id,collectionId: collectionId,personIDs: personIDs,infoMap: newInfoMap,@@ -69,7 +69,7 @@ class SmartAlbumConfig {// toJson and fromJson methodsMap<String, dynamic> toJson() {return {- "remote_id": remoteId,+ "remote_id": id,"collection_id": collectionId,"person_ids": personIDs.toList(),"updated_at": updatedAt,@@ -103,7 +103,7 @@ class SmartAlbumConfig {);return SmartAlbumConfig(- remoteId: remoteId,+ id: remoteId,collectionId: json["collection_id"] as int,personIDs: personIDs,infoMap: infoMap,@@ -112,14 +112,14 @@ class SmartAlbumConfig {}SmartAlbumConfig merge(SmartAlbumConfig b) {- if (remoteId == b.remoteId) {+ if (id == b.id) {if (updatedAt >= b.updatedAt) {return this;}return b;}return SmartAlbumConfig(- remoteId: b.updatedAt <= updatedAt ? b.remoteId : remoteId,+ id: b.updatedAt <= updatedAt ? b.id : id,collectionId: b.collectionId,personIDs: personIDs.union(b.personIDs),infoMap: {diff --git a/mobile/apps/photos/lib/service_locator.dart b/mobile/apps/photos/lib/service_locator.dartindex bc96877eb2..139f37b080 100644--- a/mobile/apps/photos/lib/service_locator.dart+++ b/mobile/apps/photos/lib/service_locator.dart@@ -14,6 +14,7 @@ import "package:photos/services/machine_learning/face_ml/face_recognition_servicimport "package:photos/services/magic_cache_service.dart";import "package:photos/services/memories_cache_service.dart";import "package:photos/services/permission/service.dart";+import "package:photos/services/smart_albums_service.dart";import "package:photos/services/smart_memories_service.dart";import "package:photos/services/storage_bonus_service.dart";import "package:photos/services/sync/trash_sync_service.dart";@@ -176,3 +177,9 @@ DownloadManager get downloadManager {);return _downloadManager!;}++SmartAlbumsService? _smartAlbumsService;+SmartAlbumsService get smartAlbumsService {+ _smartAlbumsService ??= SmartAlbumsService();+ return _smartAlbumsService!;+}diff --git a/mobile/apps/photos/lib/services/smart_albums_service.dart b/mobile/apps/photos/lib/services/smart_albums_service.dartindex b6f4e15b42..d3f1c46acd 100644--- a/mobile/apps/photos/lib/services/smart_albums_service.dart+++ b/mobile/apps/photos/lib/services/smart_albums_service.dart@@ -1,9 +1,7 @@import "dart:async";import "dart:convert";-import "package:flutter/widgets.dart" show BuildContext;import "package:logging/logging.dart";-import "package:photos/generated/l10n.dart";import "package:photos/models/api/entity/type.dart";import "package:photos/models/collection/smart_album_config.dart";import "package:photos/models/local_entity_data.dart";@@ -12,16 +10,8 @@ import "package:photos/services/collections_service.dart";import "package:photos/services/search_service.dart";import "package:photos/ui/actions/collection/collection_file_actions.dart";import "package:photos/ui/actions/collection/collection_sharing_actions.dart";-import "package:photos/ui/components/action_sheet_widget.dart"- show showActionSheet;-import "package:photos/ui/components/buttons/button_widget.dart";-import "package:photos/ui/components/models/button_type.dart";class SmartAlbumsService {- SmartAlbumsService._();-- static final SmartAlbumsService instance = SmartAlbumsService._();-final _logger = Logger((SmartAlbumsService).toString());int _lastCacheRefreshTime = 0;@@ -121,8 +111,8 @@ class SmartAlbumsService {? config.collectionId: existingConfig.collectionId;final remoteIdToDelete = config.updatedAt < existingConfig.updatedAt- ? existingConfig.remoteId- : config.remoteId;+ ? existingConfig.id+ : config.id;config = config.merge(sconfigs[config.collectionId]!);@@ -210,7 +200,7 @@ class SmartAlbumsService {await _addOrUpdateEntity(type,config.toJson(),- id: config.remoteId,+ id: config.id,);}@@ -219,43 +209,6 @@ class SmartAlbumsService {return cachedConfigs[collectionId];}- Future<bool> removeFilesDialog(- BuildContext context,- ) async {- final completer = Completer<bool>();- await showActionSheet(- context: context,- body: S.of(context).shouldRemoveFilesSmartAlbumsDesc,- buttons: [- ButtonWidget(- labelText: S.of(context).yes,- buttonType: ButtonType.neutral,- buttonSize: ButtonSize.large,- shouldStickToDarkTheme: true,- buttonAction: ButtonAction.first,- shouldSurfaceExecutionStates: true,- isInAlert: true,- onTap: () async {- completer.complete(true);- },- ),- ButtonWidget(- labelText: S.of(context).no,- buttonType: ButtonType.secondary,- buttonSize: ButtonSize.large,- shouldStickToDarkTheme: true,- buttonAction: ButtonAction.cancel,- isInAlert: true,- onTap: () async {- completer.complete(false);- },- ),- ],- );-- return completer.future;- }-/// Wrapper method for entityService.addOrUpdate that handles cache refreshFuture<LocalEntityData> _addOrUpdateEntity(EntityType type,diff --git a/mobile/apps/photos/lib/services/sync/sync_service.dart b/mobile/apps/photos/lib/services/sync/sync_service.dartindex f0fda91f91..5bc089b9a3 100644--- a/mobile/apps/photos/lib/services/sync/sync_service.dart+++ b/mobile/apps/photos/lib/services/sync/sync_service.dart@@ -13,9 +13,9 @@ import 'package:photos/events/subscription_purchased_event.dart';import 'package:photos/events/sync_status_update_event.dart';import 'package:photos/events/trigger_logout_event.dart';import 'package:photos/models/file/file_type.dart';+import "package:photos/service_locator.dart";import "package:photos/services/language_service.dart";import 'package:photos/services/notification_service.dart';-import "package:photos/services/smart_albums_service.dart";import 'package:photos/services/sync/local_sync_service.dart';import 'package:photos/services/sync/remote_sync_service.dart';import 'package:photos/utils/file_uploader.dart';@@ -200,7 +200,7 @@ class SyncService {if (shouldSync) {await _remoteSyncService.sync();}- await SmartAlbumsService.instance.syncSmartAlbums();+ await smartAlbumsService.syncSmartAlbums();}}diff --git a/mobile/apps/photos/lib/ui/collections/album/smart_album_people.dart b/mobile/apps/photos/lib/ui/collections/album/smart_album_people.dartindex 0d8703e782..d6de7f8bf6 100644--- a/mobile/apps/photos/lib/ui/collections/album/smart_album_people.dart+++ b/mobile/apps/photos/lib/ui/collections/album/smart_album_people.dart@@ -5,9 +5,10 @@ import "package:photos/db/files_db.dart";import "package:photos/generated/l10n.dart";import "package:photos/models/collection/smart_album_config.dart";import "package:photos/models/selected_people.dart";+import "package:photos/service_locator.dart";import "package:photos/services/collections_service.dart";-import "package:photos/services/smart_albums_service.dart";import "package:photos/ui/actions/collection/collection_sharing_actions.dart";+import "package:photos/ui/components/action_sheet_widget.dart";import "package:photos/ui/components/buttons/button_widget.dart";import "package:photos/ui/components/models/button_type.dart";import 'package:photos/ui/components/title_bar_title_widget.dart';@@ -39,8 +40,7 @@ class _SmartAlbumPeopleState extends State<SmartAlbumPeople> {}Future<void> getSelections() async {- currentConfig =- await SmartAlbumsService.instance.getConfig(widget.collectionId);+ currentConfig = await smartAlbumsService.getConfig(widget.collectionId);if (currentConfig != null &¤tConfig!.personIDs.isNotEmpty &&@@ -108,10 +108,7 @@ class _SmartAlbumPeopleState extends State<SmartAlbumPeople> {.toList();if (removedPersonIds.isNotEmpty) {- final toDelete =- await SmartAlbumsService.instance.removeFilesDialog(- context,- );+ final toDelete = await removeFilesDialog(context);await dialog.show();if (toDelete) {@@ -139,13 +136,13 @@ class _SmartAlbumPeopleState extends State<SmartAlbumPeople> {}}}- newConfig = await currentConfig!.getUpdatedConfig(+ newConfig = currentConfig!.getUpdatedConfig(_selectedPeople.personIds,);}- await SmartAlbumsService.instance.saveConfig(newConfig);- SmartAlbumsService.instance.syncSmartAlbums().ignore();+ await smartAlbumsService.saveConfig(newConfig);+ smartAlbumsService.syncSmartAlbums().ignore();await dialog.hide();Navigator.pop(context);@@ -180,3 +177,40 @@ class _SmartAlbumPeopleState extends State<SmartAlbumPeople> {);}}++Future<bool> removeFilesDialog(+ BuildContext context,+) async {+ final completer = Completer<bool>();+ await showActionSheet(+ context: context,+ body: S.of(context).shouldRemoveFilesSmartAlbumsDesc,+ buttons: [+ ButtonWidget(+ labelText: S.of(context).yes,+ buttonType: ButtonType.neutral,+ buttonSize: ButtonSize.large,+ shouldStickToDarkTheme: true,+ buttonAction: ButtonAction.first,+ shouldSurfaceExecutionStates: true,+ isInAlert: true,+ onTap: () async {+ completer.complete(true);+ },+ ),+ ButtonWidget(+ labelText: S.of(context).no,+ buttonType: ButtonType.secondary,+ buttonSize: ButtonSize.large,+ shouldStickToDarkTheme: true,+ buttonAction: ButtonAction.cancel,+ isInAlert: true,+ onTap: () async {+ completer.complete(false);+ },+ ),+ ],+ );++ return completer.future;+}diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dartindex d60154f9cb..7bacdd3c0b 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart@@ -27,7 +27,6 @@ import 'package:photos/models/selected_files.dart';import 'package:photos/service_locator.dart';import 'package:photos/services/collections_service.dart';import "package:photos/services/files_service.dart";-import "package:photos/services/smart_albums_service.dart";import "package:photos/states/location_screen_state.dart";import "package:photos/theme/colors.dart";import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';@@ -535,7 +534,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {? S.of(context).autoAddPeople: S.of(context).editAutoAddPeople,value: AlbumPopupAction.autoAddPhotos,- future: SmartAlbumsService.instance.getSmartConfigs,+ future: smartAlbumsService.getSmartConfigs,icon: (value) => Icons.add,),if (galleryType.canDelete())