marinofaggiana 5 years ago
parent
commit
e4e74a4bd2
3 changed files with 28 additions and 11 deletions
  1. 2 2
      iOSClient/AppDelegate.h
  2. 19 2
      iOSClient/AppDelegate.m
  3. 7 7
      iOSClient/Main/CCMain.m

+ 2 - 2
iOSClient/AppDelegate.h

@@ -109,8 +109,8 @@
 @property (nonatomic, strong) NSMutableArray *filterocId;
 
 @property (nonatomic, strong) NSMutableArray *arrayDeleteMetadata;
-@property (nonatomic, strong) NSMutableArray *arrayCopyMoveMetadata;
-@property (nonatomic, strong) NSMutableArray *arrayCopyMoveServerUrlTo;
+@property (nonatomic, strong) NSMutableArray *arrayMoveMetadata;
+@property (nonatomic, strong) NSMutableArray *arrayMoveServerUrlTo;
 
 @property (nonatomic) UIUserInterfaceStyle preferredUserInterfaceStyle API_AVAILABLE(ios(12.0));
 

+ 19 - 2
iOSClient/AppDelegate.m

@@ -84,8 +84,8 @@
     self.listProgressMetadata = [[NSMutableDictionary alloc] init];
     self.listMainVC = [[NSMutableDictionary alloc] init];
     self.arrayDeleteMetadata = [NSMutableArray new];
-    self.arrayCopyMoveMetadata = [NSMutableArray new];
-    self.arrayCopyMoveServerUrlTo = [NSMutableArray new];
+    self.arrayMoveMetadata = [NSMutableArray new];
+    self.arrayMoveServerUrlTo = [NSMutableArray new];
 
     // Push Notification
     [application registerForRemoteNotifications];
@@ -181,6 +181,7 @@
     
     // Observer
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deleteFile:) name:k_notificationCenter_deleteFile object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moveFile:) name:k_notificationCenter_moveFile object:nil];
 
     return YES;
 }
@@ -670,6 +671,22 @@
     }
 }
 
+- (void)moveFile:(NSNotification *)notification
+{
+    if (self.arrayMoveMetadata.count > 0) {
+        tableMetadata *metadata = self.arrayMoveMetadata.firstObject;
+        NSString *serverUrlTo = self.arrayMoveServerUrlTo.firstObject;
+        [self.arrayMoveMetadata removeObjectAtIndex:0];
+        [self.arrayMoveServerUrlTo removeObjectAtIndex:0];
+        tableAccount *account = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", metadata.account]];
+        if (account) {
+            [[NCNetworking sharedInstance] moveMetadata:metadata serverUrlTo:serverUrlTo overwrite:true completion:^(NSInteger errorCode, NSString *errorDescription) { }];
+        } else {
+            [self deleteFile:[NSNotification new]];
+        }
+    }
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Quick Actions - ShotcutItem =====
 #pragma --------------------------------------------------------------------------------------------

+ 7 - 7
iOSClient/Main/CCMain.m

@@ -1570,19 +1570,19 @@
      
     if ([_selectedocIdsMetadatas count] > 0) {
         for (tableMetadata *metadataSelect in _selectedocIdsMetadatas) {
-            [appDelegate.arrayCopyMoveMetadata addObject:metadataSelect];
-            [appDelegate.arrayCopyMoveServerUrlTo addObject:serverUrlTo];
+            [appDelegate.arrayMoveMetadata addObject:metadataSelect];
+            [appDelegate.arrayMoveServerUrlTo addObject:serverUrlTo];
         }
-        [appDelegate.arrayCopyMoveMetadata addObjectsFromArray:[_selectedocIdsMetadatas allValues]];
+        [appDelegate.arrayMoveMetadata addObjectsFromArray:[_selectedocIdsMetadatas allValues]];
     } else {
-        [appDelegate.arrayCopyMoveMetadata addObject:self.metadata];
-        [appDelegate.arrayCopyMoveServerUrlTo addObject:serverUrlTo];
+        [appDelegate.arrayMoveMetadata addObject:self.metadata];
+        [appDelegate.arrayMoveServerUrlTo addObject:serverUrlTo];
     }
     
     [[NCNetworking sharedInstance] moveMetadata:metadata serverUrlTo:serverUrlTo overwrite:true completion:^(NSInteger errorCode, NSString * errorDesctiption) { }];
     
-    [appDelegate.arrayCopyMoveMetadata removeObjectAtIndex:0];
-    [appDelegate.arrayCopyMoveServerUrlTo removeObjectAtIndex:0];
+    [appDelegate.arrayMoveMetadata removeObjectAtIndex:0];
+    [appDelegate.arrayMoveServerUrlTo removeObjectAtIndex:0];
 
     
     /*