@@ -250,39 +250,42 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate {
250
250
}
251
251
252
252
func tapAction( with notification: NKNotifications , label: String , sender: Any ? ) {
253
- if notification. app == NCGlobal . shared. spreedName,
254
- let roomToken = notification. objectId. split ( separator: " / " ) . first,
255
- let talkUrl = URL ( string: " nextcloudtalk://open-conversation?server= \( session. urlBase) &user= \( session. userId) &withRoomToken= \( roomToken) " ) ,
256
- UIApplication . shared. canOpenURL ( talkUrl) {
257
- UIApplication . shared. open ( talkUrl)
258
- } else if let actions = notification. actions,
259
- let jsonActions = JSON ( actions) . array,
260
- let action = jsonActions. first ( where: { $0 [ " label " ] . string == label } ) {
261
- let serverUrl = action [ " link " ] . stringValue
262
- let method = action [ " type " ] . stringValue
263
-
264
- if method == " WEB " , let url = action [ " link " ] . url {
265
- UIApplication . shared. open ( url, options: [ : ] , completionHandler: nil )
266
- return
253
+ guard let actions = notification. actions,
254
+ let jsonActions = JSON ( actions) . array,
255
+ let action = jsonActions. first ( where: { $0 [ " label " ] . string == label } )
256
+ else { return }
257
+
258
+ let serverUrl = action [ " link " ] . stringValue
259
+ let method = action [ " type " ] . stringValue
260
+
261
+ if method == " WEB " , var url = action [ " link " ] . url {
262
+ if notification. app == NCGlobal . shared. spreedName,
263
+ let roomToken = notification. objectId. split ( separator: " / " ) . first,
264
+ let talkUrl = URL ( string: " nextcloudtalk://open-conversation?server= \( session. urlBase) &user= \( session. userId) &withRoomToken= \( roomToken) " ) ,
265
+ UIApplication . shared. canOpenURL ( talkUrl) {
266
+
267
+ url = talkUrl
267
268
}
268
269
269
- NextcloudKit . shared. setNotification ( serverUrl: serverUrl, idNotification: 0 , method: method, account: session. account) { _, _, error in
270
- if error == . success {
271
- if let index = self . notifications. firstIndex ( where: { $0. idNotification == notification. idNotification } ) {
272
- self . notifications. remove ( at: index)
273
- }
274
- self . tableView. reloadData ( )
275
- if self . navigationController? . presentingViewController != nil , notification. app == NCGlobal . shared. twoFactorNotificatioName {
276
- self . dismiss ( animated: true )
277
- }
278
- } else if error != . success {
279
- NCContentPresenter ( ) . showError ( error: error)
280
- } else {
281
- print ( " [Error] The user has been changed during networking process. " )
282
- }
270
+ UIApplication . shared. open ( url)
271
+ return
272
+ }
283
273
274
+ NextcloudKit . shared. setNotification ( serverUrl: serverUrl, idNotification: 0 , method: method, account: session. account) { _, _, error in
275
+ if error == . success {
276
+ if let index = self . notifications. firstIndex ( where: { $0. idNotification == notification. idNotification } ) {
277
+ self . notifications. remove ( at: index)
278
+ }
279
+ self . tableView. reloadData ( )
280
+ if self . navigationController? . presentingViewController != nil , notification. app == NCGlobal . shared. twoFactorNotificatioName {
281
+ self . dismiss ( animated: true )
282
+ }
283
+ } else if error != . success {
284
+ NCContentPresenter ( ) . showError ( error: error)
285
+ } else {
286
+ print ( " [Error] The user has been changed during networking process. " )
284
287
}
285
- } // else: Action not found
288
+ }
286
289
}
287
290
288
291
func tapMore( with notification: NKNotifications , sender: Any ? ) {
0 commit comments