Browse Source

clear code

marinofaggiana 3 years ago
parent
commit
80c0e0c027

+ 5 - 9
iOSClient/Media/NCMedia.swift

@@ -216,7 +216,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
             if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
                 
                 if metadata.account == appDelegate.account {
-                    self.reloadDataSource()
+                    self.reloadDataSourceWithCompletion { (_) in }
                 }
             }
         }
@@ -227,7 +227,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
         if let userInfo = notification.userInfo as NSDictionary? {
             if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId), let errorCode = userInfo["errorCode"] as? Int {
                 if errorCode == 0 && metadata.account == appDelegate.account {
-                    self.reloadDataSource()
+                    self.reloadDataSourceWithCompletion { (_) in }
                 }
             }
         }
@@ -458,10 +458,6 @@ extension NCMedia {
 
     // MARK: - Datasource
 
-    @objc func reloadDataSource() {
-        self.reloadDataSourceWithCompletion { (_) in }
-    }
-    
     @objc func reloadDataSourceWithCompletion(_ completion: @escaping (_ metadatas: [tableMetadata]) -> Void) {
         
         if appDelegate.account == "" { return }
@@ -564,7 +560,7 @@ extension NCMedia {
                         if metadatasChanged.metadatasUpdate.count == 0 {
                             self.researchOldMedia(value: value, limit: limit, withElseReloadDataSource: true)
                         } else {
-                            self.reloadDataSource()
+                            self.reloadDataSourceWithCompletion { (_) in }
                         }
                     }
                 } else {
@@ -588,7 +584,7 @@ extension NCMedia {
             searchOldMedia(value: -999, limit: 0)
         } else {
             if withElseReloadDataSource {
-                reloadDataSource()
+                self.reloadDataSourceWithCompletion { (_) in }
             }
         }
     }
@@ -639,7 +635,7 @@ extension NCMedia {
                         let metadatasResult = NCManageDatabase.shared.getMetadatas(predicate: predicateResult)
                         let updateMetadatas = NCManageDatabase.shared.updateMetadatas(metadatas, metadatasResult: metadatasResult, addCompareLivePhoto: false)
                         if updateMetadatas.metadatasUpdate.count > 0 || updateMetadatas.metadatasDelete.count > 0 {
-                            self.reloadDataSource()
+                            self.reloadDataSourceWithCompletion { (_) in }
                         }
                     }
                 } else if errorCode == 0 && files.count == 0 && self.metadatas.count == 0 {

+ 5 - 5
iOSClient/Menu/NCMedia+Menu.swift

@@ -54,7 +54,7 @@ extension NCMedia {
                     action: { menuAction in
                         self.filterClassTypeImage = !self.filterClassTypeImage
                         self.filterClassTypeVideo = false
-                        self.reloadDataSource()
+                        self.reloadDataSourceWithCompletion { (_) in }
                     }
                 )
             )
@@ -68,7 +68,7 @@ extension NCMedia {
                     action: { menuAction in
                         self.filterClassTypeVideo = !self.filterClassTypeVideo
                         self.filterClassTypeImage = false
-                        self.reloadDataSource()
+                        self.reloadDataSourceWithCompletion { (_) in }
                     }
                 )
             )
@@ -98,7 +98,7 @@ extension NCMedia {
                     on: true,
                     action: { menuAction in
                         CCUtility.setMediaSortDate("date")
-                        self.reloadDataSource()
+                        self.reloadDataSourceWithCompletion { (_) in }
                     }
                 )
             )
@@ -111,7 +111,7 @@ extension NCMedia {
                     on: true,
                     action: { menuAction in
                         CCUtility.setMediaSortDate("creationDate")
-                        self.reloadDataSource()
+                        self.reloadDataSourceWithCompletion { (_) in }
                     }
                 )
             )
@@ -124,7 +124,7 @@ extension NCMedia {
                     on: true,
                     action: { menuAction in
                         CCUtility.setMediaSortDate("uploadDate")
-                        self.reloadDataSource()
+                        self.reloadDataSourceWithCompletion { (_) in }
                     }
                 )
             )

+ 1 - 1
iOSClient/Settings/CCAdvanced.m

@@ -431,7 +431,7 @@
     [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:NCGlobal.shared.notificationCenterInitialize object:nil userInfo:nil];
     
     // Clear Media
-    [appDelegate.activeMedia reloadDataSource];
+    [appDelegate.activeMedia reloadDataSourceWithCompletion:^(NSArray *metadatas) { }];
     
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
         [[NCUtility shared] stopActivityIndicator];