marinofaggiana 5 years ago
parent
commit
9365a16f94

+ 0 - 1
iOSClient/Favorites/CCFavorites.m

@@ -409,7 +409,6 @@
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_delete_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-        
         [[NCNetworking sharedInstance] deleteMetadata:metadata completion:^(NSInteger errorCode, NSString *errorDescription) { }];
     }]];
     

+ 1 - 1
iOSClient/Main/CCMain.h

@@ -91,7 +91,7 @@
 
 //expose methods for swift
 - (void)didSelectAll;
-- (void)deleteFile;
+- (void)deleteMetadatas;
 - (void)saveSelectedFiles;
 - (void)downloadSelectedFilesFolders;
 - (void)moveOpenWindow:(NSArray *)indexPaths;

+ 20 - 12
iOSClient/Main/CCMain.m

@@ -94,6 +94,8 @@
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clearDateReadDataSource:) name:@"clearDateReadDataSource" object:nil];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setTitle) name:@"setTitleMain" object:nil];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(triggerProgressTask:) name:@"NotificationProgressTask" object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deleteFile:) name:k_notificationCenter_deleteFile object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:k_notificationCenter_changeTheming object:nil];
     }
     
     return self;
@@ -191,7 +193,6 @@
     [self setTitle];
 
     // changeTheming
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:k_notificationCenter_changeTheming object:nil];
     [self changeTheming];
 }
 
@@ -431,6 +432,18 @@
     }    
 }
 
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark ==== NotificationCenter ====
+#pragma --------------------------------------------------------------------------------------------
+
+- (void)deleteFile:(NSNotification *)notification
+{
+    if (self.searchController.isActive)
+        [self readFolder:self.serverUrl];
+    else
+        [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ==== DZNEmptyDataSetSource ====
 #pragma --------------------------------------------------------------------------------------------
@@ -1411,7 +1424,7 @@
 #pragma mark ===== Delete File or Folder =====
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)deleteFile
+- (void)deleteMetadatas
 {
     if (_isSelectedMode && [_selectedocIdsMetadatas count] == 0)
         return;
@@ -1426,15 +1439,10 @@
     // remove optimization
     _dateReadDataSource = nil;
     
-    [[NCMainCommon sharedInstance ] deleteFileWithMetadatas:metadatas e2ee:_metadataFolder.e2eEncrypted serverUrl:self.serverUrl folderocId:_metadataFolder.ocId completion:^(NSInteger errorCode, NSString *message) {
-        
-        // Reload
-        if (self.searchController.isActive)
-            [self readFolder:self.serverUrl];
-        else
-            [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:self.serverUrl ocId:nil action:k_action_NULL];
-    }];
-    
+    for (tableMetadata *metadata in metadatas) {
+        [[NCNetworking sharedInstance] deleteMetadata:metadata completion:^(NSInteger errorCode, NSString *errorDescription) { }];
+    }
+
     // End Select Table View
     [self tableViewSelect:false];
 }
@@ -2657,7 +2665,7 @@
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_delete_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-        [self performSelector:@selector(deleteFile) withObject:nil];
+        [self performSelector:@selector(deleteMetadatas) withObject:nil];
     }]];
     
     if (localFile) {

+ 1 - 1
iOSClient/Main/Menu/CCMain+Menu.swift

@@ -181,7 +181,7 @@ extension CCMain {
                 title: NSLocalizedString("_delete_selected_files_", comment: ""),
                 icon: CCGraphics.changeThemingColorImage(UIImage(named: "trash"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
                 action: { menuAction in
-                    self.deleteFile()
+                    self.deleteMetadatas()
                 }
             )
         )

+ 1 - 6
iOSClient/Main/Menu/NCDetailNavigationController+Menu.swift

@@ -57,12 +57,7 @@ extension NCDetailNavigationController {
                     let alertController = UIAlertController(title: "", message: NSLocalizedString("_want_delete_", comment: ""), preferredStyle: .alert)
                     
                     alertController.addAction(UIAlertAction(title: NSLocalizedString("_yes_delete_", comment: ""), style: .default) { (action:UIAlertAction) in
-                        
-                        NCNetworking.sharedInstance.deleteMetadata(metadata) { (errorCode, errorDescription) in
-                            if errorCode == 0 {
-                                NCMainCommon.sharedInstance.reloadDatasource(ServerUrl: metadata.serverUrl, ocId: metadata.ocId, action: k_action_DEL)
-                            }
-                        }
+                        NCNetworking.sharedInstance.deleteMetadata(metadata) { (errorCode, errorDescription) in }
                     })
                     
                     alertController.addAction(UIAlertAction(title: NSLocalizedString("_no_delete_", comment: ""), style: .default) { (action:UIAlertAction) in })