Neeraj Gupta 1 年之前
父节点
当前提交
6e990f058f

+ 4 - 2
lib/models/file/extensions/file_props.dart

@@ -1,3 +1,4 @@
+import "package:photos/core/configuration.dart";
 import "package:photos/models/file/file.dart";
 import "package:photos/models/file/file_type.dart";
 
@@ -8,7 +9,8 @@ extension FilePropsExtn on EnteFile {
 
   bool get isLiveOrMotionPhoto => isLivePhoto || isMotionPhoto;
 
-  bool isOwner(int userID) => (ownerID == null) || (ownerID! == userID);
+  bool get isOwner =>
+      (ownerID == null) || (ownerID! == Configuration.instance.getUserID()!);
 
-  bool canEditMetaInfo(int userID) => isUploaded && isOwner(userID);
+  bool get canEditMetaInfo => isUploaded && isOwner;
 }

+ 0 - 1
lib/ui/viewer/file/detail_page.dart

@@ -119,7 +119,6 @@ class _DetailPageState extends State<DetailPage> {
             return FileAppBar(
               _files![selectedIndex],
               _onFileRemoved,
-              Configuration.instance.getUserID(),
               100,
               widget.config.mode == DetailPageMode.full,
               enableFullScreenNotifier: _enableFullScreenNotifier,

+ 2 - 4
lib/ui/viewer/file/file_app_bar.dart

@@ -10,6 +10,7 @@ import 'package:photos/core/event_bus.dart';
 import 'package:photos/db/files_db.dart';
 import 'package:photos/events/local_photos_updated_event.dart';
 import "package:photos/generated/l10n.dart";
+import "package:photos/models/file/extensions/file_props.dart";
 import 'package:photos/models/file/file.dart';
 import 'package:photos/models/file/file_type.dart';
 import 'package:photos/models/file/trash_file.dart';
@@ -34,13 +35,11 @@ class FileAppBar extends StatefulWidget {
   final Function(EnteFile) onFileRemoved;
   final double height;
   final bool shouldShowActions;
-  final int? userID;
   final ValueNotifier<bool> enableFullScreenNotifier;
 
   const FileAppBar(
     this.file,
     this.onFileRemoved,
-    this.userID,
     this.height,
     this.shouldShowActions, {
     required this.enableFullScreenNotifier,
@@ -94,8 +93,7 @@ class FileAppBarState extends State<FileAppBar> {
     final List<Widget> actions = [];
     final isTrashedFile = widget.file is TrashFile;
     final shouldShowActions = widget.shouldShowActions && !isTrashedFile;
-    final bool isOwnedByUser =
-        widget.file.ownerID == null || widget.file.ownerID == widget.userID;
+    final bool isOwnedByUser = widget.file.isOwner;
     final bool isFileUploaded = widget.file.isUploaded;
     bool isFileHidden = false;
     if (isOwnedByUser && isFileUploaded) {

+ 1 - 5
lib/ui/viewer/file/zoomable_live_image.dart

@@ -4,7 +4,6 @@ import 'package:chewie/chewie.dart';
 import 'package:flutter/material.dart';
 import 'package:logging/logging.dart';
 import 'package:motion_photos/motion_photos.dart';
-import "package:photos/core/configuration.dart";
 import 'package:photos/core/constants.dart';
 import "package:photos/generated/l10n.dart";
 import "package:photos/models/file/extensions/file_props.dart";
@@ -183,9 +182,7 @@ class _ZoomableLiveImageState extends State<ZoomableLiveImage>
       final index = await motionPhoto.getMotionVideoIndex();
       if (index != null) {
         // Update the metadata if it is not updated
-        if (!_enteFile.isMotionPhoto &&
-            _enteFile
-                .canEditMetaInfo(Configuration.instance.getUserID()!)) {
+        if (!_enteFile.isMotionPhoto && _enteFile.canEditMetaInfo) {
           FileMagicService.instance.updatePublicMagicMetadata(
             [_enteFile],
             {motionVideoIndexKey: index.start},
@@ -196,7 +193,6 @@ class _ZoomableLiveImageState extends State<ZoomableLiveImage>
         );
       }
     }
-
     return null;
   }