瀏覽代碼

[mob] Enable shared item action (#1638)

## Description

## Tests
Monkey tested locally
Neeraj Gupta 1 年之前
父節點
當前提交
0a57f3f955

+ 1 - 1
mobile/lib/models/gallery_type.dart

@@ -32,12 +32,12 @@ extension GalleyTypeExtension on GalleryType {
       case GalleryType.locationTag:
       case GalleryType.locationTag:
       case GalleryType.quickLink:
       case GalleryType.quickLink:
       case GalleryType.uncategorized:
       case GalleryType.uncategorized:
+      case GalleryType.sharedCollection:
         return true;
         return true;
 
 
       case GalleryType.hiddenSection:
       case GalleryType.hiddenSection:
       case GalleryType.hiddenOwnedCollection:
       case GalleryType.hiddenOwnedCollection:
       case GalleryType.trash:
       case GalleryType.trash:
-      case GalleryType.sharedCollection:
         return false;
         return false;
     }
     }
   }
   }

+ 0 - 4
mobile/lib/services/collections_service.dart

@@ -30,7 +30,6 @@ import 'package:photos/models/collection/collection_items.dart';
 import 'package:photos/models/file/file.dart';
 import 'package:photos/models/file/file.dart';
 import "package:photos/models/files_split.dart";
 import "package:photos/models/files_split.dart";
 import "package:photos/models/metadata/collection_magic.dart";
 import "package:photos/models/metadata/collection_magic.dart";
-import "package:photos/service_locator.dart";
 import 'package:photos/services/app_lifecycle_service.dart';
 import 'package:photos/services/app_lifecycle_service.dart';
 import "package:photos/services/favorites_service.dart";
 import "package:photos/services/favorites_service.dart";
 import 'package:photos/services/file_magic_service.dart';
 import 'package:photos/services/file_magic_service.dart';
@@ -1179,9 +1178,6 @@ class CollectionsService {
       await _addToCollection(dstCollectionID, splitResult.ownedByCurrentUser);
       await _addToCollection(dstCollectionID, splitResult.ownedByCurrentUser);
     }
     }
     if (splitResult.ownedByOtherUsers.isNotEmpty) {
     if (splitResult.ownedByOtherUsers.isNotEmpty) {
-      if (!flagService.internalUser) {
-        throw ArgumentError('Cannot add files owned by other users');
-      }
       late final List<EnteFile> filesToCopy;
       late final List<EnteFile> filesToCopy;
       late final List<EnteFile> filesToAdd;
       late final List<EnteFile> filesToAdd;
       (filesToAdd, filesToCopy) = (await _splitFilesToAddAndCopy(
       (filesToAdd, filesToCopy) = (await _splitFilesToAddAndCopy(

+ 3 - 12
mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart

@@ -15,7 +15,6 @@ import 'package:photos/models/files_split.dart';
 import 'package:photos/models/gallery_type.dart';
 import 'package:photos/models/gallery_type.dart';
 import "package:photos/models/metadata/common_keys.dart";
 import "package:photos/models/metadata/common_keys.dart";
 import 'package:photos/models/selected_files.dart';
 import 'package:photos/models/selected_files.dart';
-import "package:photos/service_locator.dart";
 import 'package:photos/services/collections_service.dart';
 import 'package:photos/services/collections_service.dart';
 import 'package:photos/services/hidden_service.dart';
 import 'package:photos/services/hidden_service.dart';
 import "package:photos/theme/colors.dart";
 import "package:photos/theme/colors.dart";
@@ -64,7 +63,6 @@ class _FileSelectionActionsWidgetState
   late FilesSplit split;
   late FilesSplit split;
   late CollectionActions collectionActions;
   late CollectionActions collectionActions;
   late bool isCollectionOwner;
   late bool isCollectionOwner;
-  bool _isInternalUser = false;
 
 
   // _cachedCollectionForSharedLink is primarily used to avoid creating duplicate
   // _cachedCollectionForSharedLink is primarily used to avoid creating duplicate
   // links if user keeps on creating Create link button after selecting
   // links if user keeps on creating Create link button after selecting
@@ -102,7 +100,6 @@ class _FileSelectionActionsWidgetState
 
 
   @override
   @override
   Widget build(BuildContext context) {
   Widget build(BuildContext context) {
-    _isInternalUser = flagService.internalUser;
     final ownedFilesCount = split.ownedByCurrentUser.length;
     final ownedFilesCount = split.ownedByCurrentUser.length;
     final ownedAndPendingUploadFilesCount =
     final ownedAndPendingUploadFilesCount =
         ownedFilesCount + split.pendingUploads.length;
         ownedFilesCount + split.pendingUploads.length;
@@ -150,14 +147,13 @@ class _FileSelectionActionsWidgetState
 
 
     final showUploadIcon = widget.type == GalleryType.localFolder &&
     final showUploadIcon = widget.type == GalleryType.localFolder &&
         split.ownedByCurrentUser.isEmpty;
         split.ownedByCurrentUser.isEmpty;
-    if (widget.type.showAddToAlbum() ||
-        (_isInternalUser && widget.type == GalleryType.sharedCollection)) {
+    if (widget.type.showAddToAlbum()) {
       if (showUploadIcon) {
       if (showUploadIcon) {
         items.add(
         items.add(
           SelectionActionButton(
           SelectionActionButton(
             icon: Icons.cloud_upload_outlined,
             icon: Icons.cloud_upload_outlined,
             labelText: S.of(context).addToEnte,
             labelText: S.of(context).addToEnte,
-            onTap: (anyOwnedFiles || _isInternalUser) ? _addToAlbum : null,
+            onTap: _addToAlbum,
           ),
           ),
         );
         );
       } else {
       } else {
@@ -165,8 +161,7 @@ class _FileSelectionActionsWidgetState
           SelectionActionButton(
           SelectionActionButton(
             icon: Icons.add_outlined,
             icon: Icons.add_outlined,
             labelText: S.of(context).addToAlbum,
             labelText: S.of(context).addToAlbum,
-            onTap: (anyOwnedFiles || _isInternalUser) ? _addToAlbum : null,
-            shouldShow: ownedAndPendingUploadFilesCount > 0 || _isInternalUser,
+            onTap: _addToAlbum,
           ),
           ),
         );
         );
       }
       }
@@ -450,10 +445,6 @@ class _FileSelectionActionsWidgetState
   }
   }
 
 
   Future<void> _addToAlbum() async {
   Future<void> _addToAlbum() async {
-    if (split.ownedByOtherUsers.isNotEmpty && !_isInternalUser) {
-      widget.selectedFiles
-          .unSelectAll(split.ownedByOtherUsers.toSet(), skipNotify: true);
-    }
     showCollectionActionSheet(context, selectedFiles: widget.selectedFiles);
     showCollectionActionSheet(context, selectedFiles: widget.selectedFiles);
   }
   }
 
 

+ 1 - 5
mobile/lib/ui/viewer/file/file_app_bar.dart

@@ -1,6 +1,5 @@
 import 'dart:io';
 import 'dart:io';
 
 
-import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/material.dart';
 import 'package:logging/logging.dart';
 import 'package:logging/logging.dart';
 import 'package:media_extension/media_extension.dart';
 import 'package:media_extension/media_extension.dart';
@@ -12,7 +11,6 @@ import 'package:photos/models/file/file_type.dart';
 import 'package:photos/models/file/trash_file.dart';
 import 'package:photos/models/file/trash_file.dart';
 import "package:photos/models/metadata/common_keys.dart";
 import "package:photos/models/metadata/common_keys.dart";
 import 'package:photos/models/selected_files.dart';
 import 'package:photos/models/selected_files.dart';
-import "package:photos/service_locator.dart";
 import 'package:photos/services/collections_service.dart';
 import 'package:photos/services/collections_service.dart';
 import 'package:photos/services/hidden_service.dart';
 import 'package:photos/services/hidden_service.dart';
 import 'package:photos/ui/collections/collection_action_sheet.dart';
 import 'package:photos/ui/collections/collection_action_sheet.dart';
@@ -134,9 +132,7 @@ class FileAppBarState extends State<FileAppBar> {
       );
       );
     }
     }
     // only show fav option for files owned by the user
     // only show fav option for files owned by the user
-    if ((isOwnedByUser || flagService.internalUser) &&
-        !isFileHidden &&
-        isFileUploaded) {
+    if (!isFileHidden && isFileUploaded) {
       _actions.add(FavoriteWidget(widget.file));
       _actions.add(FavoriteWidget(widget.file));
     }
     }
     if (!isFileUploaded) {
     if (!isFileUploaded) {

+ 1 - 3
mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart

@@ -90,7 +90,6 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
   String? _appBarTitle;
   String? _appBarTitle;
   late CollectionActions collectionActions;
   late CollectionActions collectionActions;
   bool isQuickLink = false;
   bool isQuickLink = false;
-  late bool isInternalUser;
   late GalleryType galleryType;
   late GalleryType galleryType;
 
 
   final ValueNotifier<int> castNotifier = ValueNotifier<int>(0);
   final ValueNotifier<int> castNotifier = ValueNotifier<int>(0);
@@ -101,7 +100,6 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
     _selectedFilesListener = () {
     _selectedFilesListener = () {
       setState(() {});
       setState(() {});
     };
     };
-    isInternalUser = flagService.internalUser;
     collectionActions = CollectionActions(CollectionsService.instance);
     collectionActions = CollectionActions(CollectionsService.instance);
     widget.selectedFiles.addListener(_selectedFilesListener);
     widget.selectedFiles.addListener(_selectedFilesListener);
     _userAuthEventSubscription =
     _userAuthEventSubscription =
@@ -416,7 +414,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
                 ? Icons.visibility_outlined
                 ? Icons.visibility_outlined
                 : Icons.visibility_off_outlined,
                 : Icons.visibility_off_outlined,
           ),
           ),
-        if (widget.collection != null && isInternalUser)
+        if (widget.collection != null)
           EntePopupMenuItem(
           EntePopupMenuItem(
             value: AlbumPopupAction.playOnTv,
             value: AlbumPopupAction.playOnTv,
             context.l10n.playOnTv,
             context.l10n.playOnTv,