marinofaggiana 4 years ago
parent
commit
fc909c8e32

+ 0 - 12
iOSClient/Favorites/NCFavorite.swift

@@ -38,18 +38,6 @@ class NCFavorite: NCCollectionViewCommon  {
         DZNdescription = "_tutorial_favorite_view_"
     }
     
-    override func viewWillAppear(_ animated: Bool) {
-        super.viewWillAppear(animated)
-        
-        if serverUrl == "" {
-            appDelegate.activeServerUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
-        } else {
-            appDelegate.activeServerUrl = serverUrl
-        }
-        
-        super.viewWillAppear(animated)
-    }
-    
     // MARK: - DataSource + NC Endpoint
     
     override func reloadDataSource() {

+ 10 - 3
iOSClient/Files/NCFiles.swift

@@ -38,9 +38,16 @@ class NCFiles: NCCollectionViewCommon  {
         DZNdescription = "_no_file_pull_down_"
     }
     
-    override func viewWillAppear(_ animated: Bool) {
-        appDelegate.activeServerUrl = serverUrl
-        super.viewWillAppear(animated)
+    // MARK: - NotificationCenter
+    
+    override func initializeMain() {
+        
+        if isRoot  {
+            serverUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
+            reloadDataSourceNetwork(forced: true)
+        }
+        
+        super.initializeMain()
     }
     
     // MARK: - DataSource + NC Endpoint

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

@@ -159,6 +159,12 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
 
+        if serverUrl == "" {
+            appDelegate.activeServerUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
+        } else {
+            appDelegate.activeServerUrl = serverUrl
+        }
+        
         appDelegate.activeViewController = self
         
         self.navigationItem.title = titleCurrentFolder
@@ -213,11 +219,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
             searchController?.isActive = false
         }
         
-        if isRoot && layoutKey == k_layout_view_files {
-            serverUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
-            reloadDataSourceNetwork(forced: true)
-        }
-        
+        // set active serverUrl
         if self.view?.window != nil {
             if serverUrl == "" {
                 appDelegate.activeServerUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)

+ 0 - 11
iOSClient/Offline/NCOffline.swift

@@ -38,17 +38,6 @@ class NCOffline: NCCollectionViewCommon  {
         DZNdescription = "_tutorial_offline_view_"
     }
     
-    override func viewWillAppear(_ animated: Bool) {
-        
-        if serverUrl == "" {
-            appDelegate.activeServerUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
-        } else {
-            appDelegate.activeServerUrl = serverUrl
-        }
-        
-        super.viewWillAppear(animated)
-    }
-    
     // MARK: - DataSource + NC Endpoint
 
     override func reloadDataSource() {

+ 0 - 4
iOSClient/Transfers/NCTransfers.swift

@@ -40,10 +40,6 @@ class NCTransfers: NCCollectionViewCommon  {
         DZNdescription = "_no_transfer_sub_"
     }
     
-    override func viewWillAppear(_ animated: Bool) {
-        super.viewWillAppear(animated)
-    }
-    
     override func setNavigationItem() {
         self.navigationItem.rightBarButtonItem = nil
         self.navigationItem.leftBarButtonItem = nil