marinofaggiana 4 years ago
parent
commit
8e41731f58
2 changed files with 39 additions and 6 deletions
  1. 9 6
      iOSClient/Main/CCMore.swift
  2. 30 0
      iOSClient/Shares/NCShares.swift

+ 9 - 6
iOSClient/Main/CCMore.swift

@@ -109,12 +109,15 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
         functionMenu.append(item)
 
         // ITEM : Shares
-        item = NCCommunicationExternalSite()
-        item.name = "_list_shares_"
-        item.icon = "shareFill"
-        item.url = "segueShares"
-        functionMenu.append(item)
-
+        let isFilesSharingEnabled = NCManageDatabase.sharedInstance.getCapabilitiesServerBool(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesFileSharingApiEnabled, exists: false)
+        if isFilesSharingEnabled {
+            item = NCCommunicationExternalSite()
+            item.name = "_list_shares_"
+            item.icon = "shareFill"
+            item.url = "segueShares"
+            functionMenu.append(item)
+        }
+        
         // ITEM : Offline
         item = NCCommunicationExternalSite()
         item.name = "_manage_file_offline_"

+ 30 - 0
iOSClient/Shares/NCShares.swift

@@ -59,6 +59,36 @@ class NCShares: NCCollectionViewCommon  {
     
     override func reloadDataSourceNetwork(forced: Bool = false) {
         super.reloadDataSourceNetwork(forced: forced)
+        
+        if isSearching {
+            networkSearch()
+            return
+        }
+                
+        isReloadDataSourceNetworkInProgress = true
+        collectionView?.reloadData()
+        
+        NCCommunication.shared.readShares { (account, shares, errorCode, ErrorDescription) in
+            
+            self.refreshControl.endRefreshing()
+            self.isReloadDataSourceNetworkInProgress = false
+            
+            if errorCode == 0 {
+                
+                NCManageDatabase.sharedInstance.deleteTableShare(account: account)
+                if shares != nil {
+                    NCManageDatabase.sharedInstance.addShare(urlBase: self.appDelegate.urlBase, account: account, shares: shares!)
+                }
+                self.appDelegate.shares = NCManageDatabase.sharedInstance.getTableShares(account: account)
+                
+                self.reloadDataSource()
+                
+            } else {
+                
+                self.collectionView?.reloadData()
+                NCContentPresenter.shared.messageNotification("_share_", description: ErrorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
+            }
+        }
     }
 }