marinofaggiana před 4 roky
rodič
revize
3101f39a1d
1 změnil soubory, kde provedl 17 přidání a 1 odebrání
  1. 17 1
      iOSClient/Media/NCMedia.swift

+ 17 - 1
iOSClient/Media/NCMedia.swift

@@ -35,6 +35,8 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
     
     public var metadatas: [tableMetadata] = []
     private var metadataPush: tableMetadata?
+    private var account: String = ""
+
     private var predicateDefault: NSPredicate?
     private var predicate: NSPredicate?
 
@@ -112,6 +114,8 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
         mediaCommandView?.heightAnchor.constraint(equalToConstant: 150).isActive = true
         self.updateMediaControlVisibility()
         
+        collectionView.prefetchDataSource = self
+        
         changeTheming()
     }
     
@@ -524,6 +528,12 @@ extension NCMedia: UICollectionViewDelegate {
     }
 }
 
+extension NCMedia: UICollectionViewDataSourcePrefetching {
+    func collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath]) {
+        print("[LOG] n. " + String(indexPaths.count))
+    }
+}
+
 extension NCMedia: UICollectionViewDataSource {
     
     func reloadDataThenPerform(_ closure: @escaping (() -> Void)) {
@@ -632,7 +642,13 @@ extension NCMedia {
     private func reloadDataSourceWithCompletion(_ completion: @escaping () -> Void) {
         
         if (appDelegate.activeAccount == nil || appDelegate.activeAccount.count == 0 || appDelegate.maintenanceMode == true) { return }
-         
+        
+        if account != appDelegate.activeAccount {
+            self.metadatas = []
+            account = appDelegate.activeAccount
+            collectionView?.reloadData()
+        }
+        
         if let tableAccount = NCManageDatabase.sharedInstance.getAccountActive() {
             self.mediaPath = tableAccount.mediaPath
         }