Selaa lähdekoodia

replace API search

marinofaggiana 5 vuotta sitten
vanhempi
commit
cfb14449fa

+ 1 - 1
Cartfile.resolved

@@ -16,7 +16,7 @@ github "kishikawakatsumi/UICKeyChainStore" "v2.1.2"
 github "krzyzanowskim/OpenSSL" "1.0.218"
 github "malcommac/SwiftRichString" "3.7.1"
 github "marinofaggiana/AFNetworking" "2967678c3e0e98c9b8d7e06222ad12d1f49c26f2"
-github "nextcloud/ios-communication-library" "81bea70b80715dad904d51696cf3dd84120b7697"
+github "nextcloud/ios-communication-library" "66643cf695c59f4d0acd3714e0b32f2b4b0eca1e"
 github "realm/realm-cocoa" "v4.4.0"
 github "rechsteiner/Parchment" "v1.7.0"
 github "scenee/FloatingPanel" "v1.7.4"

+ 0 - 1
iOSClient/Main/CCMain.h

@@ -98,7 +98,6 @@
 - (void)minCharTextFieldDidChange:(UITextField *)sender;
 - (void)comandoLockPassword;
 - (void)actionDelete:(NSIndexPath *)indexPath;
-- (void)openinFile:(id)sender;
 - (void)createRichWorkspace;
 
 @end

+ 5 - 33
iOSClient/Main/CCMain.m

@@ -1446,14 +1446,15 @@
     if (self.searchController.isActive == false) {
         return;
     }
-    
-    NSString *startDirectory = [CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl];
-    
+        
     [[NCCommunication sharedInstance] searchLiteralWithServerUrl:appDelegate.activeUrl user:appDelegate.activeUser depth:@"infinity" literal:_searchFileName account:appDelegate.activeAccount completionHandler:^(NSString *account, NSArray *files, NSInteger errorCode, NSString *errorDescription) {
         
          if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
              
-             
+              NSArray *metadatas = [[NCNetworking sharedInstance] convertFiles:files urlString:appDelegate.activeUrl serverUrl:nil user:appDelegate.activeUser metadataFolder:nil];
+             _searchResultMetadatas = [[NSMutableArray alloc] initWithArray:metadatas];
+             [self insertMetadatasWithAccount:appDelegate.activeAccount serverUrl:_serverUrl metadataFolder:nil metadatas:_searchResultMetadatas];
+                          
          } else {
              
              if (errorCode != 0) {
@@ -1467,35 +1468,6 @@
         
     }];
     
-    [[OCNetworking sharedManager] searchWithAccount:appDelegate.activeAccount fileName:_searchFileName serverUrl:startDirectory contentType:nil lteDateLastModified:nil gteDateLastModified:nil depth:@"infinity" completion:^(NSString *account, NSArray *metadatas, NSString *message, NSInteger errorCode) {
-       
-        if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
-            
-#if TARGET_OS_SIMULATOR
-            tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilitesWithAccount:account];
-            if (capabilities.isFulltextsearchEnabled) {
-                [[OCNetworking sharedManager] fullTextSearchWithAccount:appDelegate.activeAccount text:_searchFileName page:1 completion:^(NSString *account, NSArray *items, NSString *message, NSInteger errorCode) {
-                    NSLog(@"x");
-                }];
-            }
-#endif
-            
-            _searchResultMetadatas = [[NSMutableArray alloc] initWithArray:metadatas];
-            [self insertMetadatasWithAccount:appDelegate.activeAccount serverUrl:_serverUrl metadataFolder:nil metadatas:_searchResultMetadatas];
-            
-        } else {
-            
-            if (errorCode != 0) {
-                [[NCContentPresenter shared] messageNotification:@"_error_" description:message delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode];
-            } else {
-                NSLog(@"[LOG] It has been changed user during networking process, error.");
-            }
-            
-            _searchFileName = @"";
-        }
-        
-    }];
-    
     _noFilesSearchTitle = @"";
     _noFilesSearchDescription = NSLocalizedString(@"_search_in_progress_", nil);
     

+ 7 - 8
iOSClient/Media/NCMedia.swift

@@ -22,6 +22,7 @@
 //
 
 import Foundation
+import NCCommunication
 
 class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate, NCSelectDelegate {
     
@@ -618,23 +619,21 @@ extension NCMedia {
         }
         loadingSearch = true
         
-        let startDirectory = NCManageDatabase.sharedInstance.getAccountStartDirectoryMediaTabView(CCUtility.getHomeServerUrlActiveUrl(appDelegate.activeUrl))
-        
-        OCNetworking.sharedManager()?.search(withAccount: appDelegate.activeAccount, fileName: "", serverUrl: startDirectory, contentType: ["image/%", "video/%"], lteDateLastModified: lteDate, gteDateLastModified: gteDate, depth: "infinity", completion: { (account, metadatas, message, errorCode) in
+        NCCommunication.sharedInstance.searchMedia(serverUrl: appDelegate.activeUrl, user: appDelegate.activeUser, lteDateLastModified: lteDate, gteDateLastModified: gteDate, account: appDelegate.activeAccount) { (account, files, errorCode, errorDescription) in
             
             self.refreshControl.endRefreshing()
             NCUtility.sharedInstance.stopActivityIndicator()
-            //self.navigationItem.titleView = nil
-            //self.navigationItem.title = NSLocalizedString("_media_", comment: "")
             
             if errorCode == 0 && account == self.appDelegate.activeAccount {
                 
+                let metadatas = NCNetworking.sharedInstance.convertFiles(files!, urlString: self.appDelegate.activeUrl, serverUrl: nil, user: self.appDelegate.activeUser, metadataFolder: nil)
+                
                 var isDifferent: Bool = false
                 var newInsert: Int = 0
                 
                 let totalDistance = Calendar.current.dateComponents([Calendar.Component.day], from: gteDate, to: lteDate).value(for: .day) ?? 0
                 
-                let difference = NCManageDatabase.sharedInstance.createTableMedia(metadatas as! [tableMetadata], lteDate: lteDate, gteDate: gteDate, account: account!)
+                let difference = NCManageDatabase.sharedInstance.createTableMedia(metadatas, lteDate: lteDate, gteDate: gteDate, account: account)
                 isDifferent = difference.isDifferent
                 newInsert = difference.newInsert
                 
@@ -673,13 +672,13 @@ extension NCMedia {
                     self.downloadThumbnail()
                 }
                 
-            }  else {
+            } else {
                 
                 self.loadingSearch = false
                 
                 self.reloadDataSource(loadNetworkDatasource: false) { }
             }
-        })
+        }
     }
     
     @objc private func loadNetworkDatasource() {

+ 2 - 2
iOSClient/Networking/OCNetworking.h

@@ -52,8 +52,8 @@
 
 - (void)readFolderWithAccount:(NSString *)account serverUrl:(NSString *)serverUrl depth:(NSString *)depth completion:(void(^)(NSString *account, NSArray *metadatas, tableMetadata *metadataFolder, NSString *message, NSInteger errorCode))completion;
 - (void)createFolderWithAccount:(NSString *)account serverUrl:(NSString *)serverUrl fileName:(NSString *)fileName completion:(void(^)(NSString *account, NSString *ocId, NSDate *date, NSString *message, NSInteger errorCode))completion;
-- (void)searchWithAccount:(NSString *)account fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl contentType:(NSArray *)contentType lteDateLastModified:(NSDate *)lteDateLastModified gteDateLastModified:(NSDate *)gteDateLastModified depth:(NSString *)depth completion:(void(^)(NSString *account, NSArray *metadatas, NSString *message, NSInteger errorCode))completion;
-- (void)searchWithAccount:(NSString *)account folder:(NSString *)folder fileName:(NSString *)fileName dateLastModified:(NSDate *)dateLastModified numberOfItem:(NSInteger)numberOfItem completion:(void(^)(NSString *account, NSArray *metadatas, NSString *message, NSInteger errorCode))completion;
+//- (void)searchWithAccount:(NSString *)account fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl contentType:(NSArray *)contentType lteDateLastModified:(NSDate *)lteDateLastModified gteDateLastModified:(NSDate *)gteDateLastModified depth:(NSString *)depth completion:(void(^)(NSString *account, NSArray *metadatas, NSString *message, NSInteger errorCode))completion;
+//- (void)searchWithAccount:(NSString *)account folder:(NSString *)folder fileName:(NSString *)fileName dateLastModified:(NSDate *)dateLastModified numberOfItem:(NSInteger)numberOfItem completion:(void(^)(NSString *account, NSArray *metadatas, NSString *message, NSInteger errorCode))completion;
 
 #pragma mark ===== downloadPreview =====