Neeraj Gupta 1 年之前
父節點
當前提交
6ad4a71f23
共有 2 個文件被更改,包括 9 次插入3 次删除
  1. 4 0
      lib/models/file/extensions/file_props.dart
  2. 5 3
      lib/ui/viewer/file/zoomable_live_image.dart

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

@@ -7,4 +7,8 @@ extension FilePropsExtn on EnteFile {
   bool get isMotionPhoto => pubMagicMetadata?.mvi != null;
   bool get isMotionPhoto => pubMagicMetadata?.mvi != null;
 
 
   bool get isLiveOrMotionPhoto => isLivePhoto || isMotionPhoto;
   bool get isLiveOrMotionPhoto => isLivePhoto || isMotionPhoto;
+
+  bool isOwner(int userID) => (ownerID == null) || (ownerID! == userID);
+
+  bool canEditMetaInfo(int userID) => isUploaded && isOwner(userID);
 }
 }

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

@@ -182,10 +182,12 @@ class _ZoomableLiveImageState extends State<ZoomableLiveImage>
       final motionPhoto = MotionPhotos(imageFile.path);
       final motionPhoto = MotionPhotos(imageFile.path);
       final index = await motionPhoto.getMotionVideoIndex();
       final index = await motionPhoto.getMotionVideoIndex();
       if (index != null) {
       if (index != null) {
-        if (widget.enteFile.pubMagicMetadata?.mvi == null &&
-            (widget.enteFile.ownerID ?? 0) == Configuration.instance.getUserID()!) {
+        // Update the metadata if it is not updated
+        if (!_enteFile.isMotionPhoto &&
+            _enteFile
+                .canEditMetaInfo(Configuration.instance.getUserID()!)) {
           FileMagicService.instance.updatePublicMagicMetadata(
           FileMagicService.instance.updatePublicMagicMetadata(
-            [widget.enteFile],
+            [_enteFile],
             {motionVideoIndexKey: index.start},
             {motionVideoIndexKey: index.start},
           ).ignore();
           ).ignore();
         }
         }