marinofaggiana 4 years ago
parent
commit
7057771e10

+ 1 - 1
iOSClient/Favorites/NCFavorite.swift

@@ -44,7 +44,7 @@ class NCFavorite: NCCollectionViewCommon  {
         if serverUrl == "" {
             appDelegate.activeServerUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
         } else {
-            appDelegate.activeServerUrl = self.serverUrl
+            appDelegate.activeServerUrl = serverUrl
         }
         
         super.viewWillAppear(animated)

+ 15 - 7
iOSClient/Main/Collection/NCCollectionViewCommon.swift

@@ -28,14 +28,13 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
     @IBOutlet weak var collectionView: UICollectionView!
 
+    let appDelegate = UIApplication.shared.delegate as! AppDelegate
+
     internal let refreshControl = UIRefreshControl()
     internal var searchController: UISearchController?
     
-    @objc var serverUrl: String = ""
-    @objc var isRoot: Bool = true
-    
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-       
+    internal var serverUrl: String = ""
+    internal var isRoot: Bool = true
     internal var isEncryptedFolder = false
     internal var isEditMode = false
     internal var selectOcId: [String] = []
@@ -208,16 +207,25 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     // MARK: - NotificationCenter
 
     @objc func initializeMain() {
+        if appDelegate.account.count == 0 { return }
         
         if searchController?.isActive ?? false {
             searchController?.isActive = false
         }
         
-        if isRoot && layoutKey == k_layout_view_files && appDelegate.account.count > 0 {
+        if isRoot && layoutKey == k_layout_view_files {
             serverUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
             reloadDataSourceNetwork(forced: true)
         }
-                
+        
+        if self.view?.window != nil {
+            if serverUrl == "" {
+                appDelegate.activeServerUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
+            } else {
+                appDelegate.activeServerUrl = serverUrl
+            }
+        }
+        
         self.navigationController?.popToRootViewController(animated: false)
         appDelegate.listFilesVC.removeAllObjects()
         appDelegate.listFavoriteVC.removeAllObjects()

+ 1 - 1
iOSClient/Offline/NCOffline.swift

@@ -43,7 +43,7 @@ class NCOffline: NCCollectionViewCommon  {
         if serverUrl == "" {
             appDelegate.activeServerUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
         } else {
-            appDelegate.activeServerUrl = self.serverUrl
+            appDelegate.activeServerUrl = serverUrl
         }
         
         super.viewWillAppear(animated)