|
@@ -1,6 +1,6 @@
|
|
import UIKit
|
|
import UIKit
|
|
|
|
|
|
-class GroupChatDetailViewController: UIViewController {
|
|
|
|
|
|
+class GroupChatDetailViewController: UIViewController, ContactCellDelegate {
|
|
|
|
|
|
private let sectionConfig = 0
|
|
private let sectionConfig = 0
|
|
private let sectionMembers = 1
|
|
private let sectionMembers = 1
|
|
@@ -185,6 +185,8 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
|
|
contactCell.emailLabel.text = contact.email
|
|
contactCell.emailLabel.text = contact.email
|
|
contactCell.initialsLabel.text = Utils.getInitials(inputName: displayName)
|
|
contactCell.initialsLabel.text = Utils.getInitials(inputName: displayName)
|
|
contactCell.setColor(contact.color)
|
|
contactCell.setColor(contact.color)
|
|
|
|
+ contactCell.rowIndex = indexPath.row
|
|
|
|
+ contactCell.delegate = self
|
|
}
|
|
}
|
|
return cell
|
|
return cell
|
|
}
|
|
}
|
|
@@ -237,13 +239,11 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
|
|
if section == sectionMembers, row >= staticCellCountMemberSection, groupMembers[row - staticCellCountMemberSection].id != currentUser?.id {
|
|
if section == sectionMembers, row >= staticCellCountMemberSection, groupMembers[row - staticCellCountMemberSection].id != currentUser?.id {
|
|
let delete = UITableViewRowAction(style: .destructive, title: String.localized("remove_desktop")) { [unowned self] _, indexPath in
|
|
let delete = UITableViewRowAction(style: .destructive, title: String.localized("remove_desktop")) { [unowned self] _, indexPath in
|
|
|
|
|
|
- let memberId = self.groupMembers[row - self.staticCellCountMemberSection].id
|
|
|
|
- let contact = DcContact(id: memberId)
|
|
|
|
-
|
|
|
|
|
|
+ let contact = self.getGroupMember(at: row)
|
|
let title = String.localizedStringWithFormat(String.localized("ask_remove_members"), contact.nameNAddr)
|
|
let title = String.localizedStringWithFormat(String.localized("ask_remove_members"), contact.nameNAddr)
|
|
let alert = UIAlertController(title: title, message: nil, preferredStyle: .actionSheet)
|
|
let alert = UIAlertController(title: title, message: nil, preferredStyle: .actionSheet)
|
|
alert.addAction(UIAlertAction(title: String.localized("remove_desktop"), style: .destructive, handler: { _ in
|
|
alert.addAction(UIAlertAction(title: String.localized("remove_desktop"), style: .destructive, handler: { _ in
|
|
- let success = dc_remove_contact_from_chat(mailboxPointer, UInt32(self.chat.id), UInt32(memberId))
|
|
|
|
|
|
+ let success = dc_remove_contact_from_chat(mailboxPointer, UInt32(self.chat.id), UInt32(contact.id))
|
|
if success == 1 {
|
|
if success == 1 {
|
|
self.groupMembers.remove(at: row - self.staticCellCountMemberSection)
|
|
self.groupMembers.remove(at: row - self.staticCellCountMemberSection)
|
|
tableView.deleteRows(at: [indexPath], with: .fade)
|
|
tableView.deleteRows(at: [indexPath], with: .fade)
|
|
@@ -259,4 +259,15 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ func getGroupMember(at row: Int) -> DcContact {
|
|
|
|
+ let memberId = self.groupMembers[row - self.staticCellCountMemberSection].id
|
|
|
|
+ return DcContact(id: memberId)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func onAvatarTapped(at index: Int) {
|
|
|
|
+ let contact = getGroupMember(at: index)
|
|
|
|
+ coordinator?.showContactDetail(of: contact.id)
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|