Эх сурвалжийг харах

reduce calls to core when configuring WebxdcPreview

cyberta 3 жил өмнө
parent
commit
0091e8686f

+ 9 - 3
deltachat-ios/Chat/Views/WebxdcPreview.swift

@@ -60,9 +60,15 @@ public class WebxdcPreview: UIView {
     }
     
     public func configure(message: DcMsg) {
-        imagePreview.image = message.getWebxdcIcon()?.sd_resizedImage(with: CGSize(width: 175, height: 175), scaleMode: .aspectFill)
-        titleView.text = message.getWebxdcName()
-        subtitleView.text = message.getWebxdcSummary()
+        let dict = message.getWebxdcInfoDict()
+        if let iconfilePath = dict["icon"] as? String {
+            let blob = message.getWebxdcBlob(filename: iconfilePath)
+            if !blob.isEmpty {
+                imagePreview.image = UIImage(data: blob)?.sd_resizedImage(with: CGSize(width: 175, height: 175), scaleMode: .aspectFill)
+            }
+        }
+        titleView.text = dict["name"] as? String
+        subtitleView.text = dict["summary"] as? String ?? "Webxdc"
     }
 
     public func configureAccessibilityLabel() -> String {

+ 1 - 1
deltachat-ios/Controller/WebxdcViewController.swift

@@ -139,7 +139,7 @@ class WebxdcViewController: WebViewViewController {
     
     override func viewDidLoad() {
         super.viewDidLoad()
-        self.title = dcContext.getMessage(id: messageId).getWebxdcName()
+        self.title = dcContext.getMessage(id: messageId).getWebxdcInfoDict()["name"] as? String
     }
     
     override func willMove(toParent parent: UIViewController?) {

+ 0 - 24
deltachat-ios/DC/DcMsg+Extension.swift

@@ -20,28 +20,4 @@ extension DcMsg {
            }
         return [:]
     }
-
-    public func getWebxdcName() -> String? {
-        if let title = getWebxdcInfoDict()["name"] as? String {
-            return title
-        }
-        return nil
-    }
-
-    public func getWebxdcIcon() -> UIImage? {
-        if let iconfilePath = getWebxdcInfoDict()["icon"] as? String {
-            let blob = getWebxdcBlob(filename: iconfilePath)
-            if !blob.isEmpty {
-                return UIImage(data: blob)
-            }
-        }
-        return nil
-    }
-
-    public func getWebxdcSummary() -> String {
-        if let summary = getWebxdcInfoDict()["summary"] as? String {
-            return summary
-        }
-        return "Webxdc"
-    }
 }