Marino Faggiana 6 жил өмнө
parent
commit
b7c845fa1f

+ 13 - 16
iOSClient/Activity/NCActivity.swift

@@ -207,8 +207,8 @@ class NCActivity: UIViewController, UITableViewDataSource, UITableViewDelegate,
             if activity.subjectRich.count > 0 {
             if activity.subjectRich.count > 0 {
                 
                 
                 var subject = activity.subjectRich
                 var subject = activity.subjectRich
+                let keys = keyTags(text: subject)
                 
                 
-                let keys = subject.keyTags()
                 for key in keys {
                 for key in keys {
                     if let result = NCManageDatabase.sharedInstance.getActivitySubjectRich(account: appDelegate.activeAccount, idActivity: activity.idActivity, key: key) {
                     if let result = NCManageDatabase.sharedInstance.getActivitySubjectRich(account: appDelegate.activeAccount, idActivity: activity.idActivity, key: key) {
                         subject = subject.replacingOccurrences(of: "{\(key)}", with: "<bold>" + result.name + "</bold>")
                         subject = subject.replacingOccurrences(of: "{\(key)}", with: "<bold>" + result.name + "</bold>")
@@ -235,6 +235,18 @@ class NCActivity: UIViewController, UITableViewDataSource, UITableViewDelegate,
         
         
         return UITableViewCell()
         return UITableViewCell()
     }
     }
+    
+    // MARK: Utility
+    
+    func keyTags(text: String) -> [String] {
+        if let regex = try? NSRegularExpression(pattern: "\\{[a-z0-9]+\\}", options: .caseInsensitive) {
+            let string = text as NSString
+            return regex.matches(in: text, options: [], range: NSRange(location: 0, length: string.length)).map {
+                string.substring(with: $0.range).replacingOccurrences(of: "[\\{\\}]", with: "", options: .regularExpression)
+            }
+        }
+        return []
+    }
 }
 }
 
 
 class activityTableViewCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
 class activityTableViewCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
@@ -344,18 +356,3 @@ class activityCollectionViewCell: UICollectionViewCell {
         super.awakeFromNib()
         super.awakeFromNib()
     }
     }
 }
 }
-
-// MARK: Extension
-
-extension String
-{
-    func keyTags() -> [String] {
-        if let regex = try? NSRegularExpression(pattern: "\\{[a-z0-9]+\\}", options: .caseInsensitive) {
-            let string = self as NSString
-            return regex.matches(in: self, options: [], range: NSRange(location: 0, length: string.length)).map {
-                string.substring(with: $0.range).replacingOccurrences(of: "[\\{\\}]", with: "", options: .regularExpression)
-            }
-        }
-        return []
-    }
-}