marinofaggiana 5 years ago
parent
commit
7ac79d4ef9
1 changed files with 34 additions and 8 deletions
  1. 34 8
      iOSClient/Notification/CCNotification.swift

+ 34 - 8
iOSClient/Notification/CCNotification.swift

@@ -169,18 +169,44 @@ class CCNotification: UITableViewController, CCNotificationCelllDelegate {
             
         } else {
             
-            for action in notification.actions {
+            cell.primary.isEnabled = true
+            cell.primary.isHidden = false
+            
+            cell.secondary.isEnabled = true
+            cell.secondary.isHidden = false
+            
+            if notification.actions.count == 1 {
+                
+                cell.primary.isEnabled = true
+                cell.primary.isHidden = false
+                
+                cell.secondary.isEnabled = false
+                cell.secondary.isHidden = true
                 
-                let label = (action as! OCNotificationsAction).label
-                let primary = (action as! OCNotificationsAction).primary
+                let action = notification.actions[0] as! OCNotificationsAction
+                
+                cell.primary.setTitle(action.label, for: .normal)
+                
+            } else if notification.actions.count == 2 {
+            
+                cell.primary.isEnabled = true
+                cell.primary.isHidden = false
                 
-                if primary {
-                    cell.primary.setTitle(label, for: .normal)
-                } else {
-                    cell.secondary.setTitle(label, for: .normal)
+                cell.secondary.isEnabled = true
+                cell.secondary.isHidden = false
+            
+                for action in notification.actions {
+                    
+                    let label = (action as! OCNotificationsAction).label
+                    let primary = (action as! OCNotificationsAction).primary
+                    
+                    if primary {
+                        cell.primary.setTitle(label, for: .normal)
+                    } else {
+                        cell.secondary.setTitle(label, for: .normal)
+                    }
                 }
             }
-            
             let widthPrimary = cell.primary.intrinsicContentSize.width + 30;
             let widthSecondary = cell.secondary.intrinsicContentSize.width + 30;