Marino Faggiana 6 years ago
parent
commit
f816fb69a0

+ 2 - 0
iOSClient/AppDelegate.h

@@ -119,6 +119,8 @@
 @property (nonatomic, strong) NSMutableDictionary *listMainVC;
 @property (nonatomic, strong) NSMutableDictionary *listProgressMetadata;
 
+@property (nonatomic, strong) NSMutableArray *fileIDHide;
+
 // Maintenance Mode
 @property BOOL maintenanceMode;
 

+ 3 - 0
iOSClient/AppDelegate.m

@@ -176,6 +176,9 @@
     self.sharesLink = [NSMutableDictionary new];
     self.sharesUserAndGroup = [NSMutableDictionary new];
     
+    // Filter fileID
+    self.fileIDHide = [NSMutableArray new];
+
     // Initialization Notification
     self.listOfNotifications = [NSMutableArray new];
     

+ 0 - 1
iOSClient/Favorites/CCFavorites.m

@@ -318,7 +318,6 @@
             [[NCManageDatabase sharedInstance] deleteMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", fileID] clearDateReadDirectoryID:nil];
             [[NCManageDatabase sharedInstance] deleteLocalFileWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", fileID]];
             [[NCManageDatabase sharedInstance] deletePhotosWithFileID:fileID];
-            [appDelegate.activePhotos.fileIDHide addObject:fileID];
         }
     }
     

+ 0 - 1
iOSClient/Main/CCMain.h

@@ -64,7 +64,6 @@
 @property (nonatomic, strong) UIView *reMenuBackgroundView;
 @property (nonatomic, strong) UITapGestureRecognizer *singleFingerTap;
 @property (nonatomic, strong) UIImage *imageTitle;
-@property (nonatomic, strong) NSMutableArray *fileIDHide;
 @property BOOL isSelectedMode;
 
 

+ 2 - 4
iOSClient/Main/CCMain.m

@@ -135,7 +135,6 @@
     _searchFileName = @"";
     _noFilesSearchTitle = @"";
     _noFilesSearchDescription = @"";
-    self.fileIDHide = [NSMutableArray new];
     
     // delegate
     self.tableView.delegate = self;
@@ -1212,7 +1211,6 @@
             [[NCManageDatabase sharedInstance] deleteMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", fileID] clearDateReadDirectoryID:nil];
             [[NCManageDatabase sharedInstance] deleteLocalFileWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", fileID]];
             [[NCManageDatabase sharedInstance] deletePhotosWithFileID:fileID];
-            [appDelegate.activePhotos.fileIDHide addObject:fileID];
         }
         
         if ([selector isEqualToString:selectorLoadViewImage]) {
@@ -3873,7 +3871,7 @@
             }
         }
         
-        sectionDataSource = [CCSectionMetadata creataDataSourseSectionMetadata:metadatas listProgressMetadata:nil groupByField:_directoryGroupBy fileIDHide:self.fileIDHide activeAccount:appDelegate.activeAccount];
+        sectionDataSource = [CCSectionMetadata creataDataSourseSectionMetadata:metadatas listProgressMetadata:nil groupByField:_directoryGroupBy fileIDHide:appDelegate.fileIDHide activeAccount:appDelegate.activeAccount];
 
         [self tableViewReloadData];
         
@@ -3943,7 +3941,7 @@
             NSArray *recordsTableMetadata = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"directoryID == %@ AND status != %i", directoryID, k_metadataStatusHide] sorted:sorted ascending:[CCUtility getAscendingSettings]];
                                                   
             sectionDataSource = [CCSectionDataSourceMetadata new];
-            sectionDataSource = [CCSectionMetadata creataDataSourseSectionMetadata:recordsTableMetadata listProgressMetadata:nil groupByField:_directoryGroupBy fileIDHide:self.fileIDHide activeAccount:appDelegate.activeAccount];
+            sectionDataSource = [CCSectionMetadata creataDataSourseSectionMetadata:recordsTableMetadata listProgressMetadata:nil groupByField:_directoryGroupBy fileIDHide:appDelegate.fileIDHide activeAccount:appDelegate.activeAccount];
             
             // get auto upload folder
             _autoUploadFileName = [[NCManageDatabase sharedInstance] getAccountAutoUploadFileName];

+ 12 - 10
iOSClient/Main/NCMainCommon.swift

@@ -486,14 +486,18 @@ class NCMainCommon: NSObject {
     
     @objc func deleteFile(metadatas: NSArray, e2ee: Bool, serverUrl: String, folderFileID: String, completion: @escaping (_ errorCode: Int, _ message: String)->()) {
         
-        //let copyFilesID = NSArray(array:filesID as! [Any], copyItems: true)
+        var copyMetadatas = [tableMetadata]()
+        
+        for metadata in metadatas {
+            copyMetadatas.append(tableMetadata.init(value: metadata))
+        }
         
         if e2ee {
             DispatchQueue.global().async {
                 let error = NCNetworkingEndToEnd.sharedManager().lockFolderEncrypted(onServerUrl: serverUrl, fileID: folderFileID, user: self.appDelegate.activeUser, userID: self.appDelegate.activeUserID, password: self.appDelegate.activePassword, url: self.appDelegate.activeUrl)
                 DispatchQueue.main.async {
                     if error == nil {
-                        self.delete(metadatas: metadatas, serverUrl:serverUrl, e2ee: e2ee, completion: completion)
+                        self.delete(metadatas: copyMetadatas, serverUrl:serverUrl, e2ee: e2ee, completion: completion)
                     } else {
                         self.appDelegate.messageNotification("_delete_", description: error?.localizedDescription, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: Int(k_CCErrorInternalError))
                         return
@@ -501,11 +505,11 @@ class NCMainCommon: NSObject {
                 }
             }
         } else {
-            delete(metadatas: metadatas, serverUrl:serverUrl, e2ee: e2ee, completion: completion)
+            delete(metadatas: copyMetadatas, serverUrl:serverUrl, e2ee: e2ee, completion: completion)
         }
     }
     
-    private func delete(metadatas: NSArray, serverUrl: String, e2ee: Bool, completion: @escaping (_ errorCode: Int, _ message: String)->()) {
+    private func delete(metadatas: [tableMetadata], serverUrl: String, e2ee: Bool, completion: @escaping (_ errorCode: Int, _ message: String)->()) {
         
         var count: Int = 0
         var completionErrorCode: Int = 0
@@ -513,15 +517,14 @@ class NCMainCommon: NSObject {
         
         let ocNetworking = OCnetworking.init(delegate: nil, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)
         
-        for case let metadata as tableMetadata in metadatas {
+        for metadata in metadatas {
         
+            self.appDelegate.fileIDHide.add(metadata.fileID)
+            
             guard let serverUrl = NCManageDatabase.sharedInstance.getServerUrl(metadata.directoryID) else {
                 continue
             }
             
-            self.appDelegate.activeMain.fileIDHide.add(metadata.fileID)
-            self.appDelegate.activePhotos.fileIDHide.add(metadata.fileID)
-            
             ocNetworking?.deleteFileOrFolder(metadata.fileName, serverUrl: serverUrl, completion: { (message, errorCode) in
                 
                 count += 1
@@ -546,8 +549,7 @@ class NCMainCommon: NSObject {
                     
                 } else {
                     
-                    self.appDelegate.activeMain.fileIDHide.remove(metadata.fileID)
-                    self.appDelegate.activePhotos.fileIDHide.remove(metadata.fileID)
+                    self.appDelegate.fileIDHide.remove(metadata.fileID)
                     
                     completionErrorCode = errorCode
                     completionMessage = message!

+ 0 - 1
iOSClient/Photos/CCPhotos.h

@@ -43,7 +43,6 @@
 @property (nonatomic, weak) CCDetail *detailViewController;
 @property (nonatomic, strong) tableMetadata *metadata;
 @property (nonatomic, strong) NSMutableArray *addMetadatasFromUpload;
-@property (nonatomic, strong) NSMutableArray *fileIDHide;
 
 - (void)downloadFileSuccessFailure:(NSString *)fileName fileID:(NSString *)fileID serverUrl:(NSString *)serverUrl selector:(NSString *)selector errorMessage:(NSString *)errorMessage errorCode:(NSInteger)errorCode;
 

+ 1 - 3
iOSClient/Photos/CCPhotos.m

@@ -86,7 +86,6 @@
     
     saveEtagForStartDirectory = [NSMutableDictionary new];
     selectedMetadatas = [NSMutableArray new];
-    self.fileIDHide = [NSMutableArray new];
     self.addMetadatasFromUpload = [NSMutableArray new];
     
     // empty Data Source
@@ -541,7 +540,6 @@
             [self editingModeNO];
             
             // Clear all Hardcoded
-            [self.fileIDHide removeAllObjects];
             [self.addMetadatasFromUpload removeAllObjects];
             
             [[CCActions sharedInstance] search:startDirectory fileName:@"" etag:metadata.etag depth:@"infinity" date:[NSDate distantPast] contenType:@[@"image/%", @"video/%"] selector:selectorSearchContentType delegate:self];
@@ -568,7 +566,7 @@
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
 
         NSArray *metadatas = [[NCManageDatabase sharedInstance] getTablePhotosWithAddMetadatasFromUpload:self.addMetadatasFromUpload];
-        sectionDataSource = [CCSectionMetadata creataDataSourseSectionMetadata:metadatas listProgressMetadata:nil groupByField:@"date" fileIDHide:self.fileIDHide activeAccount:appDelegate.activeAccount];
+        sectionDataSource = [CCSectionMetadata creataDataSourseSectionMetadata:metadatas listProgressMetadata:nil groupByField:@"date" fileIDHide:appDelegate.fileIDHide activeAccount:appDelegate.activeAccount];
         
         dispatch_async(dispatch_get_main_queue(), ^{
                

+ 0 - 2
iOSClient/Synchronize/CCSynchronize.m

@@ -156,7 +156,6 @@
             [[NCManageDatabase sharedInstance] deleteMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", metadata.fileID] clearDateReadDirectoryID:nil];
             [[NCManageDatabase sharedInstance] deleteLocalFileWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", metadata.fileID]];
             [[NCManageDatabase sharedInstance] deletePhotosWithFileID:metadata.fileID];
-            [appDelegate.activePhotos.fileIDHide addObject:metadata.fileID];
         }
         
         dispatch_async(dispatch_get_main_queue(), ^{
@@ -315,7 +314,6 @@
                 [[NCManageDatabase sharedInstance] deleteMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", metadataNet.fileID] clearDateReadDirectoryID:nil];
                 [[NCManageDatabase sharedInstance] deleteLocalFileWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", metadataNet.fileID]];
                 [[NCManageDatabase sharedInstance] deletePhotosWithFileID:metadataNet.fileID];
-                [appDelegate.activePhotos.fileIDHide addObject:metadataNet.fileID];
                 
                 NSString *serverUrl = [[NCManageDatabase sharedInstance] getServerUrl:metadataNet.directoryID];
                 if (serverUrl)