Browse Source

dev schema nextcloud

marinofaggiana 6 years ago
parent
commit
c7322add7b
3 changed files with 47 additions and 21 deletions
  1. 11 6
      iOSClient/AppDelegate.m
  2. 0 1
      iOSClient/Main/CCMain.h
  3. 36 14
      iOSClient/Main/CCMain.m

+ 11 - 6
iOSClient/AppDelegate.m

@@ -1558,15 +1558,20 @@ PKPushRegistry *pushRegistry;
                         [tbc setSelectedIndex: k_tabBarApplicationIndexFile];
                     }
                     
+                    NSString *serverUrl = [CCUtility deletingLastPathComponentFromServerUrl:[NSString stringWithFormat:@"%@%@/%@", account.url, k_webDAV, path]];
                     NSString *fileName = [path lastPathComponent];
-                    NSString *directoryName = [[path stringByDeletingLastPathComponent] lastPathComponent];
 
-                    NSString *serverUrl = [CCUtility deletingLastPathComponentFromServerUrl:[NSString stringWithFormat:@"%@%@/%@", account.url, k_webDAV, [path stringByDeletingLastPathComponent]]];
-                                        
-                    tableMetadata *metadata = [CCUtility createMetadataWithAccount:account.account date:[NSDate date] directory:NO fileID:[[NSUUID UUID] UUIDString] serverUrl:serverUrl fileName:directoryName etag:@"" size:0 status:k_metadataStatusNormal url:@""];
-                    
-                    [self.activeMain performSegueDirectoryWithControlPasscode:true metadata:metadata scrollToFileName:fileName];
+                    if ([self.activeMain.serverUrl isEqualToString:serverUrl]) {
+                        self.activeMain.scrollToFileName = fileName;
+                        [self.activeMain readFolder:serverUrl];
+                    } else {
+                        NSString *directoryName = [[path stringByDeletingLastPathComponent] lastPathComponent];
+                        NSString *serverUrl = [CCUtility deletingLastPathComponentFromServerUrl:[NSString stringWithFormat:@"%@%@/%@", account.url, k_webDAV, [path stringByDeletingLastPathComponent]]];
 
+                        tableMetadata *metadata = [CCUtility createMetadataWithAccount:account.account date:[NSDate date] directory:NO fileID:[[NSUUID UUID] UUIDString] serverUrl:serverUrl fileName:directoryName etag:@"" size:0 status:k_metadataStatusNormal url:@""];
+                        [self.activeMain performSegueDirectoryWithControlPasscode:true metadata:metadata scrollToFileName:fileName];
+                    }
+                    
                 } else {
                     // Show add account dialog
                 }

+ 0 - 1
iOSClient/Main/CCMain.h

@@ -75,7 +75,6 @@
 
 - (void)readFolder:(NSString *)serverUrl;
 - (void)readFileReloadFolder;
-- (void)tableViewReloadData;
 
 - (void)uploadFileAsset:(NSMutableArray *)assets serverUrl:(NSString *)serverUrl useSubFolder:(BOOL)useSubFolder session:(NSString *)session;
 

+ 36 - 14
iOSClient/Main/CCMain.m

@@ -292,7 +292,7 @@
     [self setTitle];
     
     // Reload Table View
-    [self tableViewReloadData];
+    [self tableViewReloadDataWithScrollToFileName:false];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -1203,7 +1203,7 @@
         // reload
         [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:serverUrl fileID:nil action:k_action_NULL];
         
-        [self tableViewReloadData];
+        [self tableViewReloadDataWithScrollToFileName:false];
     }
     
     // E2EE Is encrypted folder get metadata
@@ -1257,7 +1257,7 @@
     
     _loadingFolder = YES;
 
-    [self tableViewReloadData];
+    [self tableViewReloadDataWithScrollToFileName:false];
     
     [[OCNetworking sharedManager] readFolderWithAccount:appDelegate.activeAccount serverUrl:serverUrl depth:@"1" completion:^(NSString *account, NSArray *metadatas, tableMetadata *metadataFolder, NSString *message, NSInteger errorCode) {
         
@@ -1927,7 +1927,7 @@
                 }
             }
             
-            [self tableViewReloadData];
+            [self tableViewReloadDataWithScrollToFileName:false];
             
         } else if (errorCode != 0) {
             
@@ -1966,7 +1966,7 @@
         if (_shareOC)
             [_shareOC reloadData];
         
-        [self tableViewReloadData];
+        [self tableViewReloadDataWithScrollToFileName:false];
     }];
     
     [_hud visibleHudTitle:NSLocalizedString(@"_creating_sharing_", nil) mode:MBProgressHUDModeIndeterminate color:nil];
@@ -2001,7 +2001,7 @@
         if (_shareOC)
             [_shareOC reloadData];
         
-        [self tableViewReloadData];
+        [self tableViewReloadDataWithScrollToFileName:false];
     }];
     
     [_hud visibleHudTitle:NSLocalizedString(@"_updating_sharing_", nil) mode:MBProgressHUDModeIndeterminate color:nil];
@@ -2028,7 +2028,7 @@
         if (_shareOC)
             [_shareOC reloadData];
         
-        [self tableViewReloadData];
+        [self tableViewReloadDataWithScrollToFileName:false];
     }];
     
     
@@ -2082,7 +2082,7 @@
         if (_shareOC)
             [_shareOC reloadData];
         
-        [self tableViewReloadData];
+        [self tableViewReloadDataWithScrollToFileName:false];
     }];
     
     [_hud visibleHudTitle:NSLocalizedString(@"_creating_sharing_", nil) mode:MBProgressHUDModeIndeterminate color:nil];
@@ -2986,7 +2986,7 @@
                     [appDelegate messageNotification:@"_error_" description:@"_error_operation_canc_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:k_CCErrorInternalError];
                 }
                 
-                [self tableViewReloadData];
+                [self tableViewReloadDataWithScrollToFileName:false];
             }
         }
             break;
@@ -3586,7 +3586,7 @@
         
         sectionDataSource = [CCSectionMetadata creataDataSourseSectionMetadata:metadatas listProgressMetadata:nil groupByField:[CCUtility getGroupBySettings] filterFileID:appDelegate.filterFileID filterTypeFileImage:NO filterTypeFileVideo:NO sorted:@"fileName" ascending:NO activeAccount:appDelegate.activeAccount];
 
-        [self tableViewReloadData];
+        [self tableViewReloadDataWithScrollToFileName:false];
         
         if ([sectionDataSource.allRecordsDataSource count] == 0 && [_searchFileName length] >= k_minCharsSearch) {
             
@@ -3642,13 +3642,13 @@
             
             dispatch_async(dispatch_get_main_queue(), ^{
                 sectionDataSource = sectionDataSourceTemp;
-                [self tableViewReloadData];
+                [self tableViewReloadDataWithScrollToFileName:true];
             });
         });
         
     } else {
         
-        [self tableViewReloadData];
+        [self tableViewReloadDataWithScrollToFileName:true];
 
          NSLog(@"[LOG] [OPTIMIZATION] Rebuild Data Source File : %@ - %@", _serverUrl, _dateReadDataSource);
     }
@@ -3674,7 +3674,7 @@
     
     if (withReloadData) {
         sectionDataSource = sectionDataSourceTemp;
-        [self tableViewReloadData];
+        [self tableViewReloadDataWithScrollToFileName:false];
     }
     
     return sectionDataSourceTemp;
@@ -3735,7 +3735,7 @@
     [self setTitle];
 }
 
-- (void)tableViewReloadData
+- (void)tableViewReloadDataWithScrollToFileName:(BOOL)withScrollToFileName
 {
     // store selected cells before relod
     NSArray *indexPaths = [self.tableView indexPathsForSelectedRows];
@@ -3754,6 +3754,28 @@
     
     //
     [self.tableView reloadEmptyDataSet];
+    
+    // scrollToFileName
+    if (self.scrollToFileName != nil && withScrollToFileName) {
+        for (NSString *key in sectionDataSource.allRecordsDataSource) {
+            tableMetadata *metadata = [sectionDataSource.allRecordsDataSource objectForKey:key];
+            if ([metadata.fileName isEqualToString:self.scrollToFileName]) {
+                for (NSString *key in sectionDataSource.fileIDIndexPath) {
+                    if ([key isEqualToString:metadata.fileID]) {
+                        NSIndexPath *indexPath = [sectionDataSource.fileIDIndexPath objectForKey:key];
+                        CCCellMain *cell = [self.tableView cellForRowAtIndexPath:indexPath];
+                        if (cell) {
+                            cell.backgroundColor = [NCBrandColor sharedInstance].brandElement;
+                            [UIView animateWithDuration:2.0 animations:^{
+                                cell.backgroundColor = [UIColor whiteColor];
+                            }];
+                        }
+                    }
+                }
+            }
+        }
+        self.scrollToFileName = nil;
+    }
 }
 
 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath