diff --git a/lib/services/collections_service.dart b/lib/services/collections_service.dart index 3ea85746c8..ae8ae150fb 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) { @@ -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"); diff --git a/lib/services/hidden_service.dart b/lib/services/hidden_service.dart index 3765fd640c..6f6457a9d8 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,18 @@ extension HiddenService on CollectionsService { _logger.finest('file already part of hidden collection'); continue; } - await move(defaultHiddenCollection.id, entry.key, entry.value); + 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( diff --git a/lib/services/machine_learning/machine_learning_controller.dart b/lib/services/machine_learning/machine_learning_controller.dart index a8a075ba34..a31da95b18 100644 --- a/lib/services/machine_learning/machine_learning_controller.dart +++ b/lib/services/machine_learning/machine_learning_controller.dart @@ -41,9 +41,14 @@ class MachineLearningController { } void onUserInteraction() { - _logger.info("User is interacting with the app"); - _isUserInteracting = true; - _fireControlEvent(); + if (Platform.isIOS) { + return; + } + if (!_isUserInteracting) { + _logger.info("User is interacting with the app"); + _isUserInteracting = true; + _fireControlEvent(); + } _resetTimer(); } 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)); 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; +} 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, + ), ), ), ), diff --git a/pubspec.lock b/pubspec.lock index fe81499044..d8e12817ad 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1397,8 +1397,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 f81d02371a..5ad591ffa9 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.64+584 publish_to: none environment: @@ -121,7 +121,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