Browse Source

add requestListTrash

marinofaggiana 6 years ago
parent
commit
59ad813f85
1 changed files with 14 additions and 0 deletions
  1. 14 0
      iOSClient/Networking/NCService.swift

+ 14 - 0
iOSClient/Networking/NCService.swift

@@ -45,6 +45,7 @@ class NCService: NSObject {
         self.requestUserProfile()
         self.requestServerCapabilities()
         self.requestServerStatus()
+        self.requestListTrash()
     }
 
     //MARK: -
@@ -308,4 +309,17 @@ class NCService: NSObject {
             
         })
     }
+    
+    private func requestListTrash() {
+        
+        let userID = (appDelegate.activeUserID as NSString).addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlFragmentAllowed)
+        let path = k_dav + "/trashbin/" + userID! + "/trash/"
+        
+        OCNetworking.sharedManager().listingTrash(withAccount: appDelegate.activeAccount, path: path, serverUrl: appDelegate.activeUrl, depth: "infinity", completion: { (account, item, message, errorCode) in
+            if errorCode == 0 && account == self.appDelegate.activeAccount {
+                NCManageDatabase.sharedInstance.deleteTrash(filePath: nil, account: account!)
+                NCManageDatabase.sharedInstance.addTrashs(item as! [tableTrash])
+            }
+        })
+    }
 }