marinofaggiana 4 年之前
父节点
当前提交
9eb1566d8b
共有 2 个文件被更改,包括 4 次插入28 次删除
  1. 3 2
      iOSClient/Favorites/CCFavorites.m
  2. 1 26
      iOSClient/Settings/CCSettings.m

+ 3 - 2
iOSClient/Favorites/CCFavorites.m

@@ -67,7 +67,8 @@
     // Notification
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(triggerProgressTask:) name:k_notificationCenter_progressTask object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:k_notificationCenter_changeTheming object:nil];
-    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadDatasource) name:k_notificationCenter_reloadDataSource object:nil];
+
     // Metadata
     self.metadata = [tableMetadata new];
     
@@ -410,7 +411,7 @@
 - (void)reloadDatasource
 {
     // test
-    if (appDelegate.activeAccount.length == 0 || self.view.window == nil) {
+    if (appDelegate.activeAccount.length == 0) { // || self.view.window == nil) {
         return;
     }
     

+ 1 - 26
iOSClient/Settings/CCSettings.m

@@ -276,7 +276,7 @@
             
             [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
                 [CCUtility setFavoriteOffline:true];
-                [self synchronizeFavorites];
+                [appDelegate.activeFavorites listingFavorites];
             }]];
             
             [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
@@ -425,31 +425,6 @@
     }
 }
 
-- (void)synchronizeFavorites
-{    
-    NSArray *metadatas = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND favorite == true", appDelegate.activeAccount]  sorted:nil ascending:NO];
-    
-    for (tableMetadata *metadata in metadatas) {
-        
-        if (metadata.directory) {
-        
-            NSString *serverUrl = [CCUtility stringAppendServerUrl:metadata.serverUrl addFileName:metadata.fileName];
-            NSString *serverUrlBeginWith = serverUrl;
-            
-            if (![serverUrl hasSuffix:@"/"])
-                serverUrlBeginWith = [serverUrl stringByAppendingString:@"/"];
-
-            NSArray *directories = [[NCManageDatabase sharedInstance] getTablesDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND (serverUrl == %@ OR serverUrl BEGINSWITH %@)", appDelegate.activeAccount, serverUrl, serverUrlBeginWith] sorted:@"serverUrl" ascending:true];
-            
-            for (tableDirectory *directory in directories) {
-                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_reloadDataSource object:nil userInfo:@{@"serverUrl": directory.serverUrl}];
-            }
-        } 
-    }
-    
-    [appDelegate.activeFavorites listingFavorites];
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark === Table View ===
 #pragma --------------------------------------------------------------------------------------------