Browse Source

dev share

marinofaggiana 5 years ago
parent
commit
1254bcbb92

+ 1 - 1
iOSClient/CCGlobal.h

@@ -81,7 +81,7 @@
 
 // Database Realm
 #define k_databaseDefault                               @"nextcloud.realm"
-#define k_databaseSchemaVersion                         58
+#define k_databaseSchemaVersion                         59
 
 // Intro selector
 #define k_intro_login                                   0

+ 0 - 1
iOSClient/Database/NCDatabase.swift

@@ -398,7 +398,6 @@ class tableShare: Object {
     @objc dynamic var permissions: Int = 0
     @objc dynamic var serverUrl = ""
     @objc dynamic var sharedDate: NSDate? = nil
-    @objc dynamic var sharedPath = ""
     @objc dynamic var shareType: Int = 0
     @objc dynamic var shareWith = ""
     @objc dynamic var shareWithDisplayName = ""

+ 51 - 53
iOSClient/Database/NCManageDatabase.swift

@@ -2257,64 +2257,62 @@ class NCManageDatabase: NSObject {
     //MARK: -
     //MARK: Table Share
     
-    @objc func addShare(account: String, activeUrl: String, items: [OCSharedDto], sharedPath: String) {
+    @objc func addShare(account: String, activeUrl: String, items: [OCSharedDto]) {
         
         let realm = try! Realm()
+        realm.beginWrite()
 
-        do {
-            try realm.write {
-
-                let results = realm.objects(tableShare.self).filter("account == %@ AND sharedPath == %@", account, sharedPath)
-                realm.delete(results)
+        let results = realm.objects(tableShare.self).filter("account == %@", account)
+        realm.delete(results)
                 
-                for sharedDto in items {
-                    
-                    let addObject = tableShare()
-                    let fullPath = CCUtility.getHomeServerUrlActiveUrl(activeUrl) + "\(sharedDto.path!)"
-                    let fileName = NSString(string: fullPath).lastPathComponent
-                    var serverUrl = NSString(string: fullPath).substring(to: (fullPath.count - fileName.count - 1))
-                    if serverUrl.hasSuffix("/") {
-                        serverUrl = NSString(string: serverUrl).substring(to: (serverUrl.count - 1))
-                    }
-                    
-                    addObject.account = account
-                    addObject.displayNameFileOwner = sharedDto.displayNameFileOwner
-                    addObject.displayNameOwner = sharedDto.displayNameOwner
-                    if sharedDto.expirationDate > 0 {
-                        addObject.expirationDate =  Date(timeIntervalSince1970: TimeInterval(sharedDto.expirationDate)) as NSDate
-                    }
-                    addObject.fileParent = sharedDto.fileParent
-                    addObject.fileTarget = sharedDto.fileTarget
-                    addObject.hideDownload = sharedDto.hideDownload
-                    addObject.idRemoteShared = sharedDto.idRemoteShared
-                    addObject.isDirectory = sharedDto.isDirectory
-                    addObject.itemSource = sharedDto.itemSource
-                    addObject.label = sharedDto.label
-                    addObject.mailSend = sharedDto.mailSend
-                    addObject.mimeType = sharedDto.mimeType
-                    addObject.note = sharedDto.note
-                    addObject.path = sharedDto.path
-                    addObject.permissions = sharedDto.permissions
-                    addObject.parent = sharedDto.parent
-                    addObject.sharedDate = Date(timeIntervalSince1970: TimeInterval(sharedDto.sharedDate)) as NSDate
-                    addObject.sharedPath = sharedPath
-                    addObject.shareType = sharedDto.shareType
-                    addObject.shareWith = sharedDto.shareWith
-                    addObject.shareWithDisplayName = sharedDto.shareWithDisplayName
-                    addObject.storage = sharedDto.storage
-                    addObject.storageID = sharedDto.storageID
-                    addObject.token = sharedDto.token
-                    addObject.url = sharedDto.url
-                    addObject.uidOwner = sharedDto.uidOwner
-                    addObject.uidFileOwner = sharedDto.uidFileOwner
-                    
-                    addObject.fileName = fileName
-                    addObject.serverUrl = serverUrl
-                    
-                    realm.add(addObject)
-                }
-        
+        for sharedDto in items {
+            
+            let addObject = tableShare()
+            let fullPath = CCUtility.getHomeServerUrlActiveUrl(activeUrl) + "\(sharedDto.path!)"
+            let fileName = NSString(string: fullPath).lastPathComponent
+            var serverUrl = NSString(string: fullPath).substring(to: (fullPath.count - fileName.count - 1))
+            if serverUrl.hasSuffix("/") {
+                serverUrl = NSString(string: serverUrl).substring(to: (serverUrl.count - 1))
             }
+            
+            addObject.account = account
+            addObject.displayNameFileOwner = sharedDto.displayNameFileOwner
+            addObject.displayNameOwner = sharedDto.displayNameOwner
+            if sharedDto.expirationDate > 0 {
+                addObject.expirationDate =  Date(timeIntervalSince1970: TimeInterval(sharedDto.expirationDate)) as NSDate
+            }
+            addObject.fileParent = sharedDto.fileParent
+            addObject.fileTarget = sharedDto.fileTarget
+            addObject.hideDownload = sharedDto.hideDownload
+            addObject.idRemoteShared = sharedDto.idRemoteShared
+            addObject.isDirectory = sharedDto.isDirectory
+            addObject.itemSource = sharedDto.itemSource
+            addObject.label = sharedDto.label
+            addObject.mailSend = sharedDto.mailSend
+            addObject.mimeType = sharedDto.mimeType
+            addObject.note = sharedDto.note
+            addObject.path = sharedDto.path
+            addObject.permissions = sharedDto.permissions
+            addObject.parent = sharedDto.parent
+            addObject.sharedDate = Date(timeIntervalSince1970: TimeInterval(sharedDto.sharedDate)) as NSDate
+            addObject.shareType = sharedDto.shareType
+            addObject.shareWith = sharedDto.shareWith
+            addObject.shareWithDisplayName = sharedDto.shareWithDisplayName
+            addObject.storage = sharedDto.storage
+            addObject.storageID = sharedDto.storageID
+            addObject.token = sharedDto.token
+            addObject.url = sharedDto.url
+            addObject.uidOwner = sharedDto.uidOwner
+            addObject.uidFileOwner = sharedDto.uidFileOwner
+            
+            addObject.fileName = fileName
+            addObject.serverUrl = serverUrl
+            
+            realm.add(addObject)
+        }
+        
+        do {
+            try realm.commitWrite()
         } catch let error {
             print("[LOG] Could not write to database: ", error)
         }

+ 8 - 4
iOSClient/Share/NCShare.swift

@@ -72,8 +72,7 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
         reloadData()
         
         let networking = NCShareNetworking.init(account: metadata!.account, activeUrl: appDelegate.activeUrl, view: nil, delegate: self)
-        networking.readShare()
-        networking.readShare(path: CCUtility.returnFileNamePath(fromFileName: metadata?.fileName, serverUrl: metadata?.serverUrl, activeUrl: appDelegate.activeUrl))
+        networking.readShare(metadata: metadata!)
     }
     
     override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
@@ -151,7 +150,7 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
         }
         
         let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self.view, delegate: self)
-        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload, metadata: metadata)
     }
     
     func tapMenu(with tableShare: tableShare?, sender: Any) {
@@ -289,9 +288,15 @@ extension NCShare: UITableViewDataSource {
         } else {
         // USER
             if let cell = tableView.dequeueReusableCell(withIdentifier: "cellUser", for: indexPath) as? NCShareUserCell {
+                
                 cell.tableShare = tableShare
                 cell.delegate = self
                 cell.labelTitle.text = tableShare.shareWith
+                cell.isUserInteractionEnabled = true
+                cell.switchCanEdit.isHidden = false
+                cell.labelCanEdit.isHidden = false
+                cell.buttonMenu.isHidden = false
+                
                 NCShareCommon.sharedInstance.downloadAvatar(user: tableShare.shareWith, cell: cell)
                 if UtilsFramework.isAnyPermission(toEdit: tableShare.permissions) {
                     cell.switchCanEdit.setOn(true, animated: false)
@@ -301,7 +306,6 @@ extension NCShare: UITableViewDataSource {
                 
                 // If the initiator or the recipient is not the current user, show the list of sharees without any options to edit it.
                 if tableShare.uidOwner != self.appDelegate.activeUserID && tableShare.uidFileOwner != self.appDelegate.activeUserID {
-                    cell.selectionStyle = .none
                     cell.isUserInteractionEnabled = false
                     cell.switchCanEdit.isHidden = true
                     cell.labelCanEdit.isHidden = true

+ 10 - 10
iOSClient/Share/NCShareLinkMenuView.swift

@@ -208,7 +208,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         }
         
         let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
-        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload, metadata: metadata)
     }
     
     // Read Only (directory)
@@ -220,7 +220,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
 
         if sender.isOn && permission != tableShare.permissions {
             let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
-            networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+            networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload, metadata: metadata)
         } else {
             sender.setOn(true, animated: false)
         }
@@ -235,7 +235,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
 
         if sender.isOn && permission != tableShare.permissions {
             let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
-            networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+            networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload, metadata: metadata)
         } else {
             sender.setOn(true, animated: false)
         }
@@ -250,7 +250,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
 
         if sender.isOn && permission != tableShare.permissions {
             let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
-            networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+            networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload, metadata: metadata)
         } else {
             sender.setOn(true, animated: false)
         }
@@ -263,7 +263,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         guard let metadata = self.metadata else { return }
 
         let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
-        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: nil, hideDownload: sender.isOn)
+        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: nil, hideDownload: sender.isOn, metadata: metadata)
     }
     
     // Password protect
@@ -278,7 +278,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
             fieldPasswordProtect.becomeFirstResponder()
         } else {
             let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
-            networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: "", permission: 0, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+            networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: "", permission: 0, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload, metadata: metadata)
         }
     }
     
@@ -288,7 +288,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         guard let metadata = self.metadata else { return }
 
         let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
-        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: fieldPasswordProtect.text, permission: 0, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: fieldPasswordProtect.text, permission: 0, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload, metadata: metadata)
     }
     
     // Set expiration date
@@ -302,7 +302,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
             fieldSetExpirationDate(sender: fieldSetExpirationDate)
         } else {
             let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
-            networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: "", hideDownload: tableShare.hideDownload)
+            networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: "", hideDownload: tableShare.hideDownload, metadata: metadata)
         }
     }
     
@@ -321,7 +321,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         if fieldNoteToRecipient.text == nil { return }
         
         let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
-        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: fieldNoteToRecipient.text, expirationTime: nil, hideDownload: tableShare.hideDownload)
+        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: fieldNoteToRecipient.text, expirationTime: nil, hideDownload: tableShare.hideDownload, metadata: metadata)
     }
     
     // Delete share link
@@ -388,7 +388,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
             let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
             dateFormatter.dateFormat = "YYYY-MM-dd"
             let expirationTime = dateFormatter.string(from: date)
-            networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: expirationTime, hideDownload: tableShare.hideDownload)
+            networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: expirationTime, hideDownload: tableShare.hideDownload, metadata: metadata)
         }
     }
     

+ 8 - 8
iOSClient/Share/NCShareNetworking.swift

@@ -46,7 +46,7 @@ class NCShareNetworking: NSObject {
             NCUtility.sharedInstance.stopActivityIndicator()
             if errorCode == 0 {
                 let itemsOCSharedDto = items as! [OCSharedDto]
-                NCManageDatabase.sharedInstance.addShare(account: self.account, activeUrl: self.activeUrl, items: itemsOCSharedDto, sharedPath: "")
+                NCManageDatabase.sharedInstance.addShare(account: self.account, activeUrl: self.activeUrl, items: itemsOCSharedDto)
             } else {
                 self.appDelegate.messageNotification("_share_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
             }
@@ -54,13 +54,13 @@ class NCShareNetworking: NSObject {
         })
     }
     
-    func readShare(path: String) {
+    func readShare(metadata: tableMetadata) {
         NCUtility.sharedInstance.startActivityIndicator(view: view, bottom: 0)
-        OCNetworking.sharedManager()?.readShare(withAccount: self.account, path: path, completion: { (account, items, message, errorCode) in
+        OCNetworking.sharedManager()?.readShare(withAccount: self.account, path: CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: activeUrl), completion: { (account, items, message, errorCode) in
             NCUtility.sharedInstance.stopActivityIndicator()
             if errorCode == 0 {
                 let itemsOCSharedDto = items as! [OCSharedDto]
-                NCManageDatabase.sharedInstance.addShare(account: self.account, activeUrl: self.activeUrl, items: itemsOCSharedDto, sharedPath:path)
+                NCManageDatabase.sharedInstance.addShare(account: self.account, activeUrl: self.activeUrl, items: itemsOCSharedDto)
             } else {
                 self.appDelegate.messageNotification("_share_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
             }
@@ -77,7 +77,7 @@ class NCShareNetworking: NSObject {
                     NCUtility.sharedInstance.stopActivityIndicator()
                     if errorCode == 0 {
                         let itemsOCSharedDto = items as! [OCSharedDto]
-                        NCManageDatabase.sharedInstance.addShare(account: self.account, activeUrl: self.activeUrl, items: itemsOCSharedDto, sharedPath: "")
+                        NCManageDatabase.sharedInstance.addShare(account: self.account, activeUrl: self.activeUrl, items: itemsOCSharedDto)
                     } else {
                         self.appDelegate.messageNotification("_share_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
                     }
@@ -103,12 +103,12 @@ class NCShareNetworking: NSObject {
         })
     }
     
-    func updateShare(idRemoteShared: Int, password: String?, permission: Int, note: String?, expirationTime: String?, hideDownload: Bool) {
+    func updateShare(idRemoteShared: Int, password: String?, permission: Int, note: String?, expirationTime: String?, hideDownload: Bool, metadata: tableMetadata) {
         NCUtility.sharedInstance.startActivityIndicator(view: view, bottom: 0)
         OCNetworking.sharedManager()?.shareUpdateAccount(account, shareID: idRemoteShared, password: password, note:note, permission: permission, expirationTime: expirationTime, hideDownload: hideDownload, completion: { (account, message, errorCode) in
             NCUtility.sharedInstance.stopActivityIndicator()
             if errorCode == 0 {
-                self.readShare()
+                self.readShare(metadata: metadata)
             } else {
                 self.appDelegate.messageNotification("_share_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
                 self.delegate?.updateShareWithError(idRemoteShared: idRemoteShared)
@@ -141,7 +141,7 @@ class NCShareNetworking: NSObject {
                     NCUtility.sharedInstance.stopActivityIndicator()
                     if errorCode == 0 {
                         let itemsOCSharedDto = items as! [OCSharedDto]
-                        NCManageDatabase.sharedInstance.addShare(account: self.account, activeUrl: self.activeUrl, items: itemsOCSharedDto, sharedPath: "")
+                        NCManageDatabase.sharedInstance.addShare(account: self.account, activeUrl: self.activeUrl, items: itemsOCSharedDto)
                     } else {
                         self.appDelegate.messageNotification("_share_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
                     }

+ 7 - 7
iOSClient/Share/NCShareUserMenuView.swift

@@ -183,7 +183,7 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         }
         
         let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
-        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload, metadata: metadata)
     }
     
     @IBAction func switchCanCreate(sender: UISwitch) {
@@ -199,7 +199,7 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         let permission = UtilsFramework.getPermissionsValue(byCanEdit: canEdit, andCanCreate: sender.isOn, andCanChange: canChange, andCanDelete: canDelete, andCanShare: canShare, andIsFolder: metadata.directory)
 
         let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
-        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload, metadata: metadata)
     }
     
     @IBAction func switchCanChange(sender: UISwitch) {
@@ -215,7 +215,7 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         let permission = UtilsFramework.getPermissionsValue(byCanEdit: canEdit, andCanCreate: canCreate, andCanChange: sender.isOn, andCanDelete: canDelete, andCanShare: canShare, andIsFolder: metadata.directory)
 
         let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
-        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload, metadata: metadata)
     }
     
     @IBAction func switchCanDelete(sender: UISwitch) {
@@ -231,7 +231,7 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         let permission = UtilsFramework.getPermissionsValue(byCanEdit: canEdit, andCanCreate: canCreate, andCanChange: canChange, andCanDelete: sender.isOn, andCanShare: canShare, andIsFolder: metadata.directory)
 
         let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
-        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
+        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload, metadata: metadata)
     }
     
     // Set expiration date
@@ -245,7 +245,7 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
             fieldSetExpirationDate(sender: fieldSetExpirationDate)
         } else {
             let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
-            networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: "", hideDownload: tableShare.hideDownload)
+            networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: "", hideDownload: tableShare.hideDownload, metadata: metadata)
         }
     }
     
@@ -264,7 +264,7 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         if fieldNoteToRecipient.text == nil { return }
         
         let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
-        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: fieldNoteToRecipient.text, expirationTime: nil, hideDownload: tableShare.hideDownload)
+        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: fieldNoteToRecipient.text, expirationTime: nil, hideDownload: tableShare.hideDownload, metadata: metadata)
     }
     
     // Unshare
@@ -321,7 +321,7 @@ class NCShareUserMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
             let networking = NCShareNetworking.init(account: metadata.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
             dateFormatter.dateFormat = "YYYY-MM-dd"
             let expirationTime = dateFormatter.string(from: date)
-            networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: expirationTime, hideDownload: tableShare.hideDownload)
+            networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: expirationTime, hideDownload: tableShare.hideDownload, metadata: metadata)
         }
     }