|
@@ -43,7 +43,6 @@
|
|
|
|
|
|
BOOL _isRoot;
|
|
|
BOOL _isViewDidLoad;
|
|
|
- BOOL isReloadDataSourceInProgress;
|
|
|
|
|
|
NSMutableDictionary *_selectedFileIDsMetadatas;
|
|
|
NSUInteger _numSelectedFileIDsMetadatas;
|
|
@@ -3742,128 +3741,101 @@
|
|
|
if (appDelegate.activeAccount.length == 0 || serverUrl.length == 0 || serverUrl == nil)
|
|
|
return;
|
|
|
|
|
|
- // ****
|
|
|
- isReloadDataSourceInProgress = YES;
|
|
|
-
|
|
|
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
- @synchronized(self) {
|
|
|
-
|
|
|
- // Search Mode
|
|
|
- if (_isSearchMode) {
|
|
|
-
|
|
|
- // Create metadatas
|
|
|
- NSMutableArray *metadatas = [NSMutableArray new];
|
|
|
- for (tableMetadata *resultMetadata in _searchResultMetadatas) {
|
|
|
- tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", resultMetadata.fileID]];
|
|
|
- if (metadata) {
|
|
|
- [metadatas addObject:metadata];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- sectionDataSource = [CCSectionMetadata creataDataSourseSectionMetadata:metadatas listProgressMetadata:nil groupByField:_directoryGroupBy filterFileID:appDelegate.filterFileID filterTypeFileImage:NO filterTypeFileVideo:NO activeAccount:appDelegate.activeAccount];
|
|
|
-
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- isReloadDataSourceInProgress = NO;
|
|
|
- [self tableViewReloadData];
|
|
|
- });
|
|
|
-
|
|
|
- if ([sectionDataSource.allRecordsDataSource count] == 0 && [_searchFileName length] >= k_minCharsSearch) {
|
|
|
-
|
|
|
- _noFilesSearchTitle = NSLocalizedString(@"_search_no_record_found_", nil);
|
|
|
- _noFilesSearchDescription = @"";
|
|
|
- }
|
|
|
-
|
|
|
- if ([sectionDataSource.allRecordsDataSource count] == 0 && [_searchFileName length] < k_minCharsSearch) {
|
|
|
-
|
|
|
- _noFilesSearchTitle = @"";
|
|
|
- _noFilesSearchDescription = NSLocalizedString(@"_search_instruction_", nil);
|
|
|
- }
|
|
|
-
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- [self.tableView reloadEmptyDataSet];
|
|
|
- });
|
|
|
-
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // Reload -> Self se non siamo nella dir appropriata cercala e se è in memoria reindirizza il reload
|
|
|
- if ([serverUrl isEqualToString:_serverUrl] == NO || _serverUrl == nil) {
|
|
|
-
|
|
|
- CCMain *main = [appDelegate.listMainVC objectForKey:serverUrl];
|
|
|
- if (main) {
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- [self reloadDatasource:serverUrl fileID:fileID action:action];
|
|
|
- });
|
|
|
- } else {
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- isReloadDataSourceInProgress = NO;
|
|
|
- [self tableViewReloadData];
|
|
|
- });
|
|
|
- }
|
|
|
- return;
|
|
|
+ // Search Mode
|
|
|
+ if (_isSearchMode) {
|
|
|
+
|
|
|
+ // Create metadatas
|
|
|
+ NSMutableArray *metadatas = [NSMutableArray new];
|
|
|
+ for (tableMetadata *resultMetadata in _searchResultMetadatas) {
|
|
|
+ tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", resultMetadata.fileID]];
|
|
|
+ if (metadata) {
|
|
|
+ [metadatas addObject:metadata];
|
|
|
}
|
|
|
-
|
|
|
- // Settaggio variabili per le ottimizzazioni
|
|
|
- _directoryGroupBy = [CCUtility getGroupBySettings];
|
|
|
- _directoryOrder = [CCUtility getOrderSettings];
|
|
|
-
|
|
|
- // Remove optimization for encrypted directory
|
|
|
- if (_metadataFolder.e2eEncrypted)
|
|
|
- _dateReadDataSource = nil;
|
|
|
-
|
|
|
- // current directoryID
|
|
|
- NSString *directoryID = [[NCManageDatabase sharedInstance] getDirectoryID:serverUrl];
|
|
|
+ }
|
|
|
+
|
|
|
+ sectionDataSource = [CCSectionMetadata creataDataSourseSectionMetadata:metadatas listProgressMetadata:nil groupByField:_directoryGroupBy filterFileID:appDelegate.filterFileID filterTypeFileImage:NO filterTypeFileVideo:NO activeAccount:appDelegate.activeAccount];
|
|
|
|
|
|
- // Controllo data lettura Data Source
|
|
|
- tableDirectory *tableDirectory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, serverUrl]];
|
|
|
- // Get MetadataFolder
|
|
|
- if (![serverUrl isEqualToString:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl]])
|
|
|
- _metadataFolder = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", tableDirectory.fileID]];
|
|
|
+ [self tableViewReloadData];
|
|
|
+
|
|
|
+ if ([sectionDataSource.allRecordsDataSource count] == 0 && [_searchFileName length] >= k_minCharsSearch) {
|
|
|
|
|
|
- NSDate *dateDateRecordDirectory = tableDirectory.dateReadDirectory;
|
|
|
+ _noFilesSearchTitle = NSLocalizedString(@"_search_no_record_found_", nil);
|
|
|
+ _noFilesSearchDescription = @"";
|
|
|
+ }
|
|
|
+
|
|
|
+ if ([sectionDataSource.allRecordsDataSource count] == 0 && [_searchFileName length] < k_minCharsSearch) {
|
|
|
|
|
|
- if ([dateDateRecordDirectory compare:_dateReadDataSource] == NSOrderedDescending || dateDateRecordDirectory == nil || _dateReadDataSource == nil) {
|
|
|
-
|
|
|
- NSLog(@"[LOG] Rebuild Data Source File : %@", _serverUrl);
|
|
|
+ _noFilesSearchTitle = @"";
|
|
|
+ _noFilesSearchDescription = NSLocalizedString(@"_search_instruction_", nil);
|
|
|
+ }
|
|
|
+
|
|
|
+ [self.tableView reloadEmptyDataSet];
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Reload -> Self se non siamo nella dir appropriata cercala e se è in memoria reindirizza il reload
|
|
|
+ if ([serverUrl isEqualToString:_serverUrl] == NO || _serverUrl == nil) {
|
|
|
+
|
|
|
+ CCMain *main = [appDelegate.listMainVC objectForKey:serverUrl];
|
|
|
+ if (main) {
|
|
|
+ [main reloadDatasource:serverUrl fileID:fileID action:action];
|
|
|
+ } else {
|
|
|
+ [self tableViewReloadData];
|
|
|
+ }
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Settaggio variabili per le ottimizzazioni
|
|
|
+ _directoryGroupBy = [CCUtility getGroupBySettings];
|
|
|
+ _directoryOrder = [CCUtility getOrderSettings];
|
|
|
+
|
|
|
+ // Remove optimization for encrypted directory
|
|
|
+ if (_metadataFolder.e2eEncrypted)
|
|
|
+ _dateReadDataSource = nil;
|
|
|
+
|
|
|
+ // current directoryID
|
|
|
+ NSString *directoryID = [[NCManageDatabase sharedInstance] getDirectoryID:serverUrl];
|
|
|
|
|
|
- _dateReadDataSource = [NSDate date];
|
|
|
-
|
|
|
- // Data Source
|
|
|
-
|
|
|
- NSString *sorted = _directoryOrder;
|
|
|
- if ([sorted isEqualToString:@"fileName"])
|
|
|
- sorted = @"fileName";
|
|
|
-
|
|
|
- if (directoryID) {
|
|
|
-
|
|
|
- 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 filterFileID:appDelegate.filterFileID filterTypeFileImage:NO filterTypeFileVideo:NO activeAccount:appDelegate.activeAccount];
|
|
|
-
|
|
|
- // get auto upload folder
|
|
|
- _autoUploadFileName = [[NCManageDatabase sharedInstance] getAccountAutoUploadFileName];
|
|
|
- _autoUploadDirectory = [[NCManageDatabase sharedInstance] getAccountAutoUploadDirectory:appDelegate.activeUrl];
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- NSLog(@"[LOG] [OPTIMIZATION] Rebuild Data Source File : %@ - %@", _serverUrl, _dateReadDataSource);
|
|
|
- }
|
|
|
+ // Controllo data lettura Data Source
|
|
|
+ tableDirectory *tableDirectory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, serverUrl]];
|
|
|
+ // Get MetadataFolder
|
|
|
+ if (![serverUrl isEqualToString:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl]])
|
|
|
+ _metadataFolder = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", tableDirectory.fileID]];
|
|
|
+
|
|
|
+ NSDate *dateDateRecordDirectory = tableDirectory.dateReadDirectory;
|
|
|
+
|
|
|
+ if ([dateDateRecordDirectory compare:_dateReadDataSource] == NSOrderedDescending || dateDateRecordDirectory == nil || _dateReadDataSource == nil) {
|
|
|
+
|
|
|
+ NSLog(@"[LOG] Rebuild Data Source File : %@", _serverUrl);
|
|
|
+
|
|
|
+ _dateReadDataSource = [NSDate date];
|
|
|
+
|
|
|
+ // Data Source
|
|
|
+
|
|
|
+ NSString *sorted = _directoryOrder;
|
|
|
+ if ([sorted isEqualToString:@"fileName"])
|
|
|
+ sorted = @"fileName";
|
|
|
+
|
|
|
+ if (directoryID) {
|
|
|
+
|
|
|
+ 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 filterFileID:appDelegate.filterFileID filterTypeFileImage:NO filterTypeFileVideo:NO activeAccount:appDelegate.activeAccount];
|
|
|
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- if (fileID) {
|
|
|
- NSIndexPath *indexPath = [sectionDataSource.fileIDIndexPath objectForKey:fileID];
|
|
|
- if (indexPath && [self indexPathIsValid:indexPath] && action == k_action_MOD) {
|
|
|
- [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationTop];
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- isReloadDataSourceInProgress = NO;
|
|
|
- [self tableViewReloadData];
|
|
|
- });
|
|
|
+ // get auto upload folder
|
|
|
+ _autoUploadFileName = [[NCManageDatabase sharedInstance] getAccountAutoUploadFileName];
|
|
|
+ _autoUploadDirectory = [[NCManageDatabase sharedInstance] getAccountAutoUploadDirectory:appDelegate.activeUrl];
|
|
|
}
|
|
|
- });
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ NSLog(@"[LOG] [OPTIMIZATION] Rebuild Data Source File : %@ - %@", _serverUrl, _dateReadDataSource);
|
|
|
+ }
|
|
|
+
|
|
|
+ [self tableViewReloadData];
|
|
|
}
|
|
|
|
|
|
- (NSArray *)getMetadatasFromSelectedRows:(NSArray *)selectedRows
|
|
@@ -3923,10 +3895,6 @@
|
|
|
|
|
|
- (void)tableViewReloadData
|
|
|
{
|
|
|
- //
|
|
|
- if (isReloadDataSourceInProgress)
|
|
|
- return;
|
|
|
-
|
|
|
// store selected cells before relod
|
|
|
NSArray *indexPaths = [self.tableView indexPathsForSelectedRows];
|
|
|
|