From dac1847ffdd596844877267630d8122db0cd369e Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:25:24 +0530 Subject: [PATCH 01/11] Collection:move use named params --- lib/services/collections_service.dart | 8 +++--- lib/services/hidden_service.dart | 26 ++++++++++++------- .../collection_sharing_actions.dart | 4 +-- lib/ui/collections/album/vertical_list.dart | 4 +-- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/lib/services/collections_service.dart b/lib/services/collections_service.dart index 3ea85746c8..5cceece1b5 100644 --- a/lib/services/collections_service.dart +++ b/lib/services/collections_service.dart @@ -1372,10 +1372,10 @@ class CollectionsService { } Future move( - int toCollectionID, - int fromCollectionID, - List files, - ) async { + List files, { + required int toCollectionID, + required int fromCollectionID, + }) async { _validateMoveRequest(toCollectionID, fromCollectionID, files); files.removeWhere((element) => element.uploadedFileID == null); if (files.isEmpty) { diff --git a/lib/services/hidden_service.dart b/lib/services/hidden_service.dart index 3765fd640c..7d1672fa03 100644 --- a/lib/services/hidden_service.dart +++ b/lib/services/hidden_service.dart @@ -57,21 +57,25 @@ extension HiddenService on CollectionsService { Future clubAllDefaultHiddenToOne( List allDefaultHidden, ) async { - final Collection result = allDefaultHidden.first; - - for (Collection defaultHidden in allDefaultHidden) { + // select first collection as default hidden where all files will be clubbed + final Collection defaultHidden = allDefaultHidden.first; + for (Collection hidden in allDefaultHidden) { try { - if (defaultHidden.id == result.id) { + if (hidden.id == defaultHidden.id) { continue; } final filesInCollection = (await FilesDB.instance.getFilesInCollection( - defaultHidden.id, + hidden.id, galleryLoadStartTime, galleryLoadEndTime, )) .files; - await move(result.id, defaultHidden.id, filesInCollection); - await CollectionsService.instance.trashEmptyCollection(defaultHidden); + await move( + filesInCollection, + toCollectionID: defaultHidden.id, + fromCollectionID: hidden.id, + ); + await CollectionsService.instance.trashEmptyCollection(hidden); } catch (e, s) { _logger.severe( "One iteration of clubbing all default hidden failed", @@ -82,7 +86,7 @@ extension HiddenService on CollectionsService { } } - return result; + return defaultHidden; } // getUncategorizedCollection will return the uncategorized collection @@ -137,7 +141,11 @@ extension HiddenService on CollectionsService { _logger.finest('file already part of hidden collection'); continue; } - await move(defaultHiddenCollection.id, entry.key, entry.value); + await move( + entry.value, + toCollectionID: defaultHiddenCollection.id, + fromCollectionID: entry.key, + ); } Bus.instance.fire( LocalPhotosUpdatedEvent( diff --git a/lib/ui/actions/collection/collection_sharing_actions.dart b/lib/ui/actions/collection/collection_sharing_actions.dart index 01eddfac2d..1e3ac0d95a 100644 --- a/lib/ui/actions/collection/collection_sharing_actions.dart +++ b/lib/ui/actions/collection/collection_sharing_actions.dart @@ -558,9 +558,9 @@ class CollectionActions { ); } else { await collectionsService.move( - entry.key, - collection.id, entry.value, + toCollectionID: entry.key, + fromCollectionID: collection.id, ); } } diff --git a/lib/ui/collections/album/vertical_list.dart b/lib/ui/collections/album/vertical_list.dart index 4c65d44f26..fd5814f183 100644 --- a/lib/ui/collections/album/vertical_list.dart +++ b/lib/ui/collections/album/vertical_list.dart @@ -398,9 +398,9 @@ class AlbumVerticalListWidget extends StatelessWidget { try { final int fromCollectionID = selectedFiles!.files.first.collectionID!; await CollectionsService.instance.move( - toCollectionID, - fromCollectionID, selectedFiles!.files.toList(), + toCollectionID: toCollectionID, + fromCollectionID: fromCollectionID, ); await dialog.hide(); unawaited(RemoteSyncService.instance.sync(silently: true)); From 7c7f76a461d0750156cf7e127016f4632f6b7d0c Mon Sep 17 00:00:00 2001 From: vishnukvmd Date: Thu, 22 Feb 2024 17:16:31 +0530 Subject: [PATCH 02/11] v0.8.62 --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index f61844d738..66ffe2de7f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ description: ente photos application # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.8.61+581 +version: 0.8.62+582 environment: sdk: ">=3.0.0 <4.0.0" From e89d32355f5dcb5a933ef18a31ed6f1c3138d352 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:52:16 +0530 Subject: [PATCH 03/11] [Hide] Remove files from collections owned by others --- lib/services/hidden_service.dart | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/services/hidden_service.dart b/lib/services/hidden_service.dart index 7d1672fa03..6f6457a9d8 100644 --- a/lib/services/hidden_service.dart +++ b/lib/services/hidden_service.dart @@ -141,11 +141,18 @@ extension HiddenService on CollectionsService { _logger.finest('file already part of hidden collection'); continue; } - await move( - entry.value, - toCollectionID: defaultHiddenCollection.id, - fromCollectionID: entry.key, - ); + final Collection? c = getCollectionByID(entry.key); + // if the collection is not owned by the user, remove the file from the + // collection + if (c != null && !c.isOwner(userID)) { + await removeFromCollection(entry.key, entry.value); + } else { + await move( + entry.value, + toCollectionID: defaultHiddenCollection.id, + fromCollectionID: entry.key, + ); + } } Bus.instance.fire( LocalPhotosUpdatedEvent( From 4ce6c8592ed84555dbc18026fb1c92dfde816335 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:55:40 +0530 Subject: [PATCH 04/11] Improve assertion checks for move ops --- lib/services/collections_service.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/services/collections_service.dart b/lib/services/collections_service.dart index 5cceece1b5..ae8ae150fb 100644 --- a/lib/services/collections_service.dart +++ b/lib/services/collections_service.dart @@ -1443,9 +1443,19 @@ class CollectionsService { int fromCollectionID, List files, ) { + final int userID = Configuration.instance.getUserID()!; if (toCollectionID == fromCollectionID) { throw AssertionError("Can't move to same album"); } + final Collection? toCollection = _collectionIDToCollections[toCollectionID]; + final Collection? fromCollection = + _collectionIDToCollections[fromCollectionID]; + if (toCollection != null && !toCollection.isOwner(userID)) { + throw AssertionError("Can't move to a collection you don't own"); + } + if (fromCollection != null && !fromCollection.isOwner(userID)) { + throw AssertionError("Can't move from a collection you don't own"); + } for (final file in files) { if (file.uploadedFileID == null) { throw AssertionError("Can only move uploaded memories"); From 2ce2aad6c67f50bbb946d5d44850be2d98fc3bf7 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Fri, 23 Feb 2024 12:31:12 +0530 Subject: [PATCH 05/11] Revert "Switch to stripe for all" This reverts commit 9a1e8da5007b65ecc4a361c5277b2f909015337d. --- lib/ui/payment/subscription.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/ui/payment/subscription.dart b/lib/ui/payment/subscription.dart index 067a3ae102..0327c3ab53 100644 --- a/lib/ui/payment/subscription.dart +++ b/lib/ui/payment/subscription.dart @@ -1,4 +1,5 @@ import 'package:flutter/cupertino.dart'; +import 'package:photos/core/configuration.dart'; import 'package:photos/services/feature_flag_service.dart'; import 'package:photos/services/update_service.dart'; import "package:photos/ui/payment/store_subscription_page.dart"; @@ -8,9 +9,18 @@ StatefulWidget getSubscriptionPage({bool isOnBoarding = false}) { if (UpdateService.instance.isIndependentFlavor()) { return StripeSubscriptionPage(isOnboarding: isOnBoarding); } - if (FeatureFlagService.instance.enableStripe()) { + if (FeatureFlagService.instance.enableStripe() && + _isUserCreatedPostStripeSupport()) { return StripeSubscriptionPage(isOnboarding: isOnBoarding); } else { return StoreSubscriptionPage(isOnboarding: isOnBoarding); } } + +// return true if the user was created after we added support for stripe payment +// on frame. We do this check to avoid showing Stripe payment option for earlier +// users who might have paid via playStore. This method should be removed once +// we have better handling for active play/app store subscription & stripe plans. +bool _isUserCreatedPostStripeSupport() { + return Configuration.instance.getUserID()! > 1580559962386460; +} From e4eb100d42eb68cc0a411deceb4120cc63c561e1 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Fri, 23 Feb 2024 12:32:05 +0530 Subject: [PATCH 06/11] Bump version 0.8.63+583 --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 66ffe2de7f..fc7c0a9267 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ description: ente photos application # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.8.62+582 +version: 0.8.63+583 environment: sdk: ">=3.0.0 <4.0.0" From 18e1c39c603e04757774ec3f6119faf73b50fd5d Mon Sep 17 00:00:00 2001 From: vishnukvmd Date: Sat, 24 Feb 2024 11:04:32 +0530 Subject: [PATCH 07/11] Don't log for every interaction --- .../machine_learning/machine_learning_controller.dart | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/services/machine_learning/machine_learning_controller.dart b/lib/services/machine_learning/machine_learning_controller.dart index a8a075ba34..a00bb6dcb5 100644 --- a/lib/services/machine_learning/machine_learning_controller.dart +++ b/lib/services/machine_learning/machine_learning_controller.dart @@ -41,9 +41,11 @@ class MachineLearningController { } void onUserInteraction() { - _logger.info("User is interacting with the app"); - _isUserInteracting = true; - _fireControlEvent(); + if (!_isUserInteracting) { + _logger.info("User is interacting with the app"); + _isUserInteracting = true; + _fireControlEvent(); + } _resetTimer(); } From d486500d8b76d28a92d4bb54f1684c4c7fffb057 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Sat, 24 Feb 2024 11:59:27 +0530 Subject: [PATCH 08/11] add scrollbar in logs viewer screen --- lib/ui/tools/debug/log_file_viewer.dart | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/ui/tools/debug/log_file_viewer.dart b/lib/ui/tools/debug/log_file_viewer.dart index 9efefaf7ed..9e3e00789d 100644 --- a/lib/ui/tools/debug/log_file_viewer.dart +++ b/lib/ui/tools/debug/log_file_viewer.dart @@ -42,14 +42,16 @@ class _LogFileViewerState extends State { } return Container( padding: const EdgeInsets.only(left: 12, top: 8, right: 12), - child: SingleChildScrollView( - child: Text( - _logs!, - style: const TextStyle( - fontFeatures: [ - FontFeature.tabularFigures(), - ], - height: 1.2, + child: Scrollbar( + child: SingleChildScrollView( + child: Text( + _logs!, + style: const TextStyle( + fontFeatures: [ + FontFeature.tabularFigures(), + ], + height: 1.2, + ), ), ), ), From 511b2239e3c666cf8c3dcf2deaa144557a3beaba Mon Sep 17 00:00:00 2001 From: vishnukvmd Date: Sat, 24 Feb 2024 16:20:54 +0530 Subject: [PATCH 09/11] Pin the reference to git dependency --- pubspec.lock | 4 ++-- pubspec.yaml | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 15aa46017e..aa2e0230e5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1389,8 +1389,8 @@ packages: dependency: "direct main" description: path: "." - ref: HEAD - resolved-ref: "1318dce97f3aae5ec9bdf7491d5eff0ad6beb378" + ref: "5f26aef45ed9f5e563c26f90c1e21b3339ed906d" + resolved-ref: "5f26aef45ed9f5e563c26f90c1e21b3339ed906d" url: "https://github.com/ente-io/onnxruntime.git" source: git version: "1.1.0" diff --git a/pubspec.yaml b/pubspec.yaml index fc7c0a9267..5374135207 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -118,7 +118,9 @@ dependencies: # open_file: ^3.2.1 onnxruntime: - git: "https://github.com/ente-io/onnxruntime.git" + git: + url: https://github.com/ente-io/onnxruntime.git + ref: 5f26aef45ed9f5e563c26f90c1e21b3339ed906d open_mail_app: ^0.4.5 package_info_plus: ^4.1.0 page_transition: ^2.0.2 From 52f4d2f634b23a08b566295eadcc96fff32ba604 Mon Sep 17 00:00:00 2001 From: vishnukvmd Date: Sat, 24 Feb 2024 16:23:25 +0530 Subject: [PATCH 10/11] Ignore user interaction events on iOS --- lib/services/machine_learning/machine_learning_controller.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/services/machine_learning/machine_learning_controller.dart b/lib/services/machine_learning/machine_learning_controller.dart index a00bb6dcb5..a31da95b18 100644 --- a/lib/services/machine_learning/machine_learning_controller.dart +++ b/lib/services/machine_learning/machine_learning_controller.dart @@ -41,6 +41,9 @@ class MachineLearningController { } void onUserInteraction() { + if (Platform.isIOS) { + return; + } if (!_isUserInteracting) { _logger.info("User is interacting with the app"); _isUserInteracting = true; From 89a07240f3c06df06b881986de06d9d27e040f2f Mon Sep 17 00:00:00 2001 From: vishnukvmd Date: Sat, 24 Feb 2024 16:27:41 +0530 Subject: [PATCH 11/11] Up version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 5374135207..9948146a6f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ description: ente photos application # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.8.63+583 +version: 0.8.64+584 environment: sdk: ">=3.0.0 <4.0.0"