Marino Faggiana 6 年之前
父节点
当前提交
bd8bdde573
共有 2 个文件被更改,包括 17 次插入28 次删除
  1. 16 27
      iOSClient/Media/NCMedia.swift
  2. 1 1
      iOSClient/Networking/NCService.swift

+ 16 - 27
iOSClient/Media/NCMedia.swift

@@ -37,6 +37,9 @@ class NCMedia: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
     private var isEditMode = false
     private var selectFileID = [String]()
     
+    private var filterTypeFileImage = false;
+    private var filterTypeFileVideo = false;
+    
     private var sectionDatasource = CCSectionDataSourceMetadata()
     
     private var typeLayout = ""
@@ -403,39 +406,25 @@ class NCMedia: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
     // MARK: DATASOURCE
     @objc func loadDatasource() {
         
-        var fileIDs = [String]()
-        sectionDatasource = CCSectionDataSourceMetadata()
-
-        if serverUrl == "" {
+        if appDelegate.activeAccount.count == 0 {
+            return
+        }
         
-            if let directories = NCManageDatabase.sharedInstance.getTablesDirectory(predicate: NSPredicate(format: "account == %@ AND offline == true", appDelegate.activeAccount), sorted: "serverUrl", ascending: true) {
-                for directory: tableDirectory in directories {
-                    fileIDs.append(directory.fileID)
-                }
-            }
-          
-            if let files = NCManageDatabase.sharedInstance.getTableLocalFiles(predicate: NSPredicate(format: "account == %@ AND offline == true", appDelegate.activeAccount), sorted: "fileName", ascending: true) {
-                for file: tableLocalFile in files {
-                    fileIDs.append(file.fileID)
-                }
-            }
+        let startDirectory = NCManageDatabase.sharedInstance.getAccountStartDirectoryMediaTabView(CCUtility.getHomeServerUrlActiveUrl(appDelegate.activeUrl))
+        let date = Calendar.current.date(byAdding: .day, value: -30, to: Date())
+        
+        OCNetworking.sharedManager()?.search(withAccount: appDelegate.activeAccount, fileName: "", serverUrl: startDirectory, contentType: ["image/%", "video/%"], date: date, depth: "infinity", completion: { (account, metadatas, message, errorCode) in
             
-            if let metadatas = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND fileID IN %@", appDelegate.activeAccount, fileIDs), sorted: datasourceSorted, ascending: datasourceAscending)  {
+            if errorCode == 0 && account == self.appDelegate.activeAccount {
+                NCManageDatabase.sharedInstance.createTablePhotos(metadatas as! [tableMetadata], account: account!)
+                
+                self.sectionDatasource = CCSectionMetadata.creataDataSourseSectionMetadata(metadatas, listProgressMetadata: nil, groupByField: "date", filterFileID: nil, filterTypeFileImage: self.filterTypeFileImage, filterTypeFileVideo: self.filterTypeFileVideo, activeAccount: account!)
+                self.collectionView.reloadData()
 
-                sectionDatasource = CCSectionMetadata.creataDataSourseSectionMetadata(metadatas, listProgressMetadata: nil, groupByField: datasourceGroupBy, filterFileID: nil, filterTypeFileImage: false, filterTypeFileVideo: false, activeAccount: appDelegate.activeAccount)
             }
-            
-        } else {
-        
-            if let metadatas = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.activeAccount, serverUrl), sorted: datasourceSorted, ascending: datasourceAscending)  {
+        })
                 
-                sectionDatasource = CCSectionMetadata.creataDataSourseSectionMetadata(metadatas, listProgressMetadata: nil, groupByField: datasourceGroupBy, filterFileID: nil, filterTypeFileImage: false, filterTypeFileVideo: false, activeAccount: appDelegate.activeAccount)
-            }
-        }
-        
         self.refreshControl.endRefreshing()
-        
-        collectionView.reloadData()
     }
     
     // MARK: COLLECTIONVIEW METHODS

+ 1 - 1
iOSClient/Networking/NCService.swift

@@ -245,7 +245,7 @@ class NCService: NSObject {
                 
                 // Call func thath required the userdID
                 self.appDelegate.activeFavorites.listingFavorites()
-                self.appDelegate.activeMedia.searchPhotoVideo()
+                //self.appDelegate.activeMedia.searchPhotoVideo()
                 NCFunctionMain.sharedInstance.synchronizeOffline()
                 
                 DispatchQueue.global(qos: .default).async {