Browse Source

NCNotification

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 1 year ago
parent
commit
5da8cc83ee
2 changed files with 13 additions and 1 deletions
  1. 1 0
      iOSClient/NCGlobal.swift
  2. 12 1
      iOSClient/Notification/NCNotification.swift

+ 1 - 0
iOSClient/NCGlobal.swift

@@ -90,6 +90,7 @@ class NCGlobal: NSObject {
     //
     let appName                                     = "files"
     let talkName                                    = "talk-message"
+    let spreedName                                  = "spreed"
     let twofactorNotificatioName                    = "twofactor_nextcloud_notification"
     let appScheme                                   = "nextcloud"
 

+ 12 - 1
iOSClient/Notification/NCNotification.swift

@@ -49,6 +49,13 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
 
         refreshControl?.addTarget(self, action: #selector(getNetwokingNotification), for: .valueChanged)
 
+        // Navigation controller is being presented modally
+        if navigationController?.presentingViewController != nil {
+            navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: .plain, action: { [weak self] in
+                self?.dismiss(animated: true)
+            })
+        }
+
         // Empty
         let offset = (self.navigationController?.navigationBar.bounds.height ?? 0) - 20
         emptyDataSet = NCEmptyDataSet(view: tableView, offset: -offset, delegate: self)
@@ -258,7 +265,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
     }
 
     func tapAction(with notification: NKNotifications, label: String) {
-        if notification.app == "spreed",
+        if notification.app == NCGlobal.shared.spreedName,
            let roomToken = notification.objectId.split(separator: "/").first,
            let talkUrl = URL(string: "nextcloudtalk://open-conversation?server=\(appDelegate.urlBase)&user=\(appDelegate.userId)&withRoomToken=\(roomToken)"),
            UIApplication.shared.canOpenURL(talkUrl) {
@@ -280,11 +287,15 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
                         self.notifications.remove(at: index)
                     }
                     self.tableView.reloadData()
+                    if self.navigationController?.presentingViewController != nil, notification.app == NCGlobal.shared.twofactorNotificatioName {
+                        self.dismiss(animated: true)
+                    }
                 } else if error != .success {
                     NCContentPresenter.shared.showError(error: error)
                 } else {
                     print("[Error] The user has been changed during networking process.")
                 }
+
             }
         } // else: Action not found
     }