marinofaggiana 4 years ago
parent
commit
4d0c0914f1
2 changed files with 14 additions and 20 deletions
  1. 1 1
      Cartfile.resolved
  2. 13 19
      iOSClient/Media/NCMedia.swift

+ 1 - 1
Cartfile.resolved

@@ -20,7 +20,7 @@ github "marinofaggiana/AFNetworking" "2967678c3e0e98c9b8d7e06222ad12d1f49c26f2"
 github "marinofaggiana/KTVHTTPCache" "2.0.2"
 github "marinofaggiana/TOPasscodeViewController" "0.0.6"
 github "marinofaggiana/XLForm" "eb9381ad8129f60402bf412250fb31b95a628a08"
-github "nextcloud/ios-communication-library" "69f515b0a47a3f172f9c0d950d4e29c434adf474"
+github "nextcloud/ios-communication-library" "c8161e5ca01af886adde953339829563e527b315"
 github "realm/realm-cocoa" "v4.4.1"
 github "rechsteiner/Parchment" "v1.7.0"
 github "scenee/FloatingPanel" "v1.7.5"

+ 13 - 19
iOSClient/Media/NCMedia.swift

@@ -79,6 +79,8 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
     override func viewDidLoad() {
         super.viewDidLoad()
         
+        self.navigationItem.title = NSLocalizedString("_media_", comment: "")
+
         self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: CCGraphics.changeThemingColorImage(UIImage(named: "more"), width: 50, height: 50, color: NCBrandColor.sharedInstance.textView), style: .plain, target: self, action: #selector(touchUpInsideMenuButtonMore))
         
         // Cell
@@ -135,7 +137,6 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
             self.mediaCommandView?.isHidden = true
         }
         
-        collectionView.reloadData()
         changeTheming()
     }
     
@@ -181,13 +182,6 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
     
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
-        
-        // get auto upload folder
-        autoUploadFileName = NCManageDatabase.sharedInstance.getAccountAutoUploadFileName()
-        autoUploadDirectory = NCManageDatabase.sharedInstance.getAccountAutoUploadDirectory(appDelegate.activeUrl)
-        
-        // Title
-        self.navigationItem.title = NSLocalizedString("_media_", comment: "")
     }
     
     override func viewDidAppear(_ animated: Bool) {
@@ -631,6 +625,7 @@ extension NCMedia {
         
         if newInProgress { return }
         else { newInProgress = true }
+        collectionView.reloadData()
         
         let tableAccount = NCManageDatabase.sharedInstance.getAccountActive()
         
@@ -648,16 +643,18 @@ extension NCMedia {
         NCCommunication.shared.searchMedia(lteDate: lteDate, gteDate: gteDate, elementDate: "d:getlastmodified/" ,showHiddenFiles: CCUtility.getShowHiddenFiles(), user: appDelegate.activeUser) { (account, files, errorCode, errorDescription) in
             
             self.newInProgress = false
+            self.collectionView.reloadData()
 
             if errorCode == 0 && files != nil && files!.count > 0 {
+                
                 NCManageDatabase.sharedInstance.addMetadatas(files: files, account: self.appDelegate.activeAccount)
                 if tableAccount?.dateLteMedia == nil {
                     NCManageDatabase.sharedInstance.setAccountDateLteMedia(date: files?.last?.date)
                 }
                 NCManageDatabase.sharedInstance.setAccountDateUpdateMedia()
+                
+                self.reloadDataSource()
             }
-            
-            self.reloadDataSource()
         }
     }
     
@@ -665,7 +662,8 @@ extension NCMedia {
         
         if oldInProgress { return }
         else { oldInProgress = true }
-        
+        collectionView.reloadData()
+
         var lteDate = Date()
         let tableAccount = NCManageDatabase.sharedInstance.getAccountActive()
         if let date = tableAccount?.dateLteMedia {
@@ -685,17 +683,13 @@ extension NCMedia {
             
             self.oldInProgress = false
             NCUtility.sharedInstance.stopActivityIndicator()
-            
+            self.collectionView.reloadData()
+
             if errorCode == 0 {
                 if files != nil && files!.count > 0 {
-                    NCManageDatabase.sharedInstance.addMetadatas(files: files, account: self.appDelegate.activeAccount)
-                    
-                    var lastDate = files?.last?.date
-                    if lastDate != nil && lastDate == tableAccount?.dateLteMedia {
-                        lastDate = Calendar.current.date(byAdding: .second, value: -1, to: lastDate! as Date) as NSDate?
-                    }
                     
-                    NCManageDatabase.sharedInstance.setAccountDateLteMedia(date: lastDate)
+                    NCManageDatabase.sharedInstance.addMetadatas(files: files, account: self.appDelegate.activeAccount)
+                    NCManageDatabase.sharedInstance.setAccountDateLteMedia(date: files?.last?.date)
                     self.reloadDataSource()
                     
                 } else {