Marino Faggiana 7 年 前
コミット
5da8287255
1 ファイル変更16 行追加11 行削除
  1. 16 11
      iOSClient/Photos/CCPhotos.m

+ 16 - 11
iOSClient/Photos/CCPhotos.m

@@ -597,21 +597,26 @@
 #pragma --------------------------------------------------------------------------------------------
 
 - (void)reloadDatasource
-{    
-    // test
-    if (appDelegate.activeAccount.length == 0)
-        return;
+{
+    @synchronized(self) {
+        // test
+        if (appDelegate.activeAccount.length == 0)
+            return;
     
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
 
-        NSArray *results = [[NCManageDatabase sharedInstance] getTableMetadatasContentTypeImageVideo];
-        CCSectionDataSourceMetadata *tempSectionDataSource = [CCSectionMetadata creataDataSourseSectionMetadata:results listProgressMetadata:nil groupByField:@"date" activeAccount:appDelegate.activeAccount];
+            NSArray *results = [[NCManageDatabase sharedInstance] getTableMetadatasContentTypeImageVideo];
+            CCSectionDataSourceMetadata *tempSectionDataSource = [CCSectionMetadata creataDataSourseSectionMetadata:results listProgressMetadata:nil groupByField:@"date" activeAccount:appDelegate.activeAccount];
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            _sectionDataSource = [tempSectionDataSource copy];
-            [self reloadCollection];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                // OPTIMIZED
+                if (tempSectionDataSource.totalSize != _sectionDataSource.totalSize || tempSectionDataSource.files != _sectionDataSource.files) {
+                    _sectionDataSource = [tempSectionDataSource copy];
+                    [self reloadCollection];
+                }
+            });
         });
-    });
+    }
 }
 
 - (void)reloadCollection