Преглед изворни кода

show mailinglist address in profile (#1654)

* add Chat::getMailinglistAddr()

* remove superfuous code: the attributes are overwritten/set in viewWillAppear -> updateHeader

* show mailinglist address in profile
bjoern пре 3 година
родитељ
комит
d7c4ea5273

+ 7 - 0
DcCore/DcCore/DC/Wrapper.swift

@@ -887,6 +887,13 @@ public class DcChat {
         return DcUtils.copyAndFreeArray(inputArray: dc_get_chat_contacts(dcContext.contextPointer, UInt32(id)))
         return DcUtils.copyAndFreeArray(inputArray: dc_get_chat_contacts(dcContext.contextPointer, UInt32(id)))
     }
     }
 
 
+    public func getMailinglistAddr() -> String {
+        guard let cString = dc_chat_get_mailinglist_addr(chatPointer) else { return "" }
+        let swiftString = String(cString: cString)
+        dc_str_unref(cString)
+        return swiftString
+    }
+
     public lazy var profileImage: UIImage? = {
     public lazy var profileImage: UIImage? = {
         guard let cString = dc_chat_get_profile_image(chatPointer) else { return nil }
         guard let cString = dc_chat_get_profile_image(chatPointer) else { return nil }
         let filename = String(cString: cString)
         let filename = String(cString: cString)

+ 7 - 11
deltachat-ios/Controller/GroupChatDetailViewController.swift

@@ -87,17 +87,7 @@ class GroupChatDetailViewController: UIViewController {
 
 
     private lazy var groupHeader: ContactDetailHeader = {
     private lazy var groupHeader: ContactDetailHeader = {
         let header = ContactDetailHeader()
         let header = ContactDetailHeader()
-        header.updateDetails(
-            title: chat.name,
-            subtitle: String.localizedStringWithFormat(String.localized("n_members"), chat.getContactIds(dcContext).count)
-        )
-        if let img = chat.profileImage {
-            header.setImage(img)
-        } else {
-            header.setBackupImage(name: chat.name, color: chat.color)
-        }
         header.onAvatarTap = showGroupAvatarIfNeeded
         header.onAvatarTap = showGroupAvatarIfNeeded
-        header.setVerified(isVerified: chat.isProtected)
         header.showMuteButton(show: chat.isMuted)
         header.showMuteButton(show: chat.isMuted)
         header.showSearchButton(show: true)
         header.showSearchButton(show: true)
         header.onSearchButtonTapped = showSearch
         header.onSearchButtonTapped = showSearch
@@ -320,7 +310,13 @@ class GroupChatDetailViewController: UIViewController {
     }
     }
 
 
     private func updateHeader() {
     private func updateHeader() {
-        groupHeader.updateDetails(title: chat.name, subtitle: nil)
+        var subtitle: String?
+        if chat.isMailinglist {
+            let addr = chat.getMailinglistAddr()
+            subtitle = addr.isEmpty ? nil : addr
+        }
+        groupHeader.updateDetails(title: chat.name, subtitle: subtitle)
+
         if let img = chat.profileImage {
         if let img = chat.profileImage {
             groupHeader.setImage(img)
             groupHeader.setImage(img)
         } else {
         } else {