Переглянути джерело

Fix optional metadata for Activity view

Viewing Activities in "More" tab have not metadata and just display all activities.
Also, can't make general comments without a fileId.
Henrik Storch 3 роки тому
батько
коміт
5b33096aa3
2 змінених файлів з 22 додано та 15 видалено
  1. 21 15
      iOSClient/Activity/NCActivity.swift
  2. 1 0
      iOSClient/Share/NCSharePaging.swift

+ 21 - 15
iOSClient/Activity/NCActivity.swift

@@ -40,6 +40,7 @@ class NCActivity: UIViewController {
     var height: CGFloat = 0
 
     var metadata: tableMetadata?
+    var showCommetns: Bool = false
 
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
 
@@ -71,8 +72,12 @@ class NCActivity: UIViewController {
         NotificationCenter.default.addObserver(self, selector: #selector(self.changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
         
         changeTheming()
-        
-        setupComments()
+
+        if showCommetns {
+            setupComments()
+        } else {
+            commentView.isHidden = true
+        }
     }
     
     func setupComments() {
@@ -360,29 +365,30 @@ extension NCActivity: UIScrollViewDelegate {
 extension NCActivity {
 
     func loadDataSource() {
-        
-        guard let metadata = self.metadata else { return }
+
         NCUtility.shared.startActivityIndicator(backgroundView: tableView, blurEffect: false)
         let reloadDispatch = DispatchGroup()
         self.allItems = []
         reloadDispatch.enter()
-        reloadDispatch.enter()
-
-        NCCommunication.shared.getComments(fileId: metadata.fileId) { (account, comments, errorCode, errorDescription) in
-            if errorCode == 0 && comments != nil {
-                NCManageDatabase.shared.addComments(comments!, account: metadata.account, objectId: metadata.fileId)
-                self.allItems += NCManageDatabase.shared.getComments(account: metadata.account, objectId: metadata.fileId)
-                reloadDispatch.leave()
-            } else {
-                if errorCode != NCGlobal.shared.errorResourceNotFound {
-                    NCContentPresenter.shared.messageNotification("_share_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
+        if showCommetns, let metadata = metadata {
+            reloadDispatch.enter()
+            
+            NCCommunication.shared.getComments(fileId: metadata.fileId) { (account, comments, errorCode, errorDescription) in
+                if errorCode == 0 && comments != nil {
+                    NCManageDatabase.shared.addComments(comments!, account: metadata.account, objectId: metadata.fileId)
+                    self.allItems += NCManageDatabase.shared.getComments(account: metadata.account, objectId: metadata.fileId)
+                    reloadDispatch.leave()
+                } else {
+                    if errorCode != NCGlobal.shared.errorResourceNotFound {
+                        NCContentPresenter.shared.messageNotification("_share_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
+                    }
                 }
             }
         }
         
         let activities = NCManageDatabase.shared.getActivity(
             predicate: NSPredicate(format: "account == %@", appDelegate.account),
-            filterFileId: metadata.fileId)
+            filterFileId: metadata?.fileId)
         self.allItems += activities.filter
         reloadDispatch.leave()
         

+ 1 - 0
iOSClient/Share/NCSharePaging.swift

@@ -177,6 +177,7 @@ extension NCSharePaging: PagingViewControllerDataSource {
         case .activity:
             let viewController = UIStoryboard(name: "NCActivity", bundle: nil).instantiateInitialViewController() as! NCActivity
             viewController.height = height
+            viewController.showCommetns = true
             viewController.didSelectItemEnable = false
             viewController.metadata = metadata
             viewController.objectType = "files"