Skip to content

Commit

Permalink
open NewGroupController on cloning and pass templateChatId
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed Nov 12, 2023
1 parent 6e15612 commit 88ea3df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
toggleArchiveChat()
case .cloneChat:
tableView.deselectRow(at: indexPath, animated: false)
navigationController?.pushViewController(NewGroupController(dcContext: dcContext, createBroadcast: chat.isBroadcast, templateChatId: chatId), animated: true)
case .leaveGroup:
tableView.deselectRow(at: indexPath, animated: false)
showLeaveGroupConfirmationAlert()
Expand Down
14 changes: 13 additions & 1 deletion deltachat-ios/Controller/NewGroupController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class NewGroupController: UITableViewController, MediaPickerDelegate {
var doneButton: UIBarButtonItem!
var contactIdsForGroup: Set<Int>
var groupContactIds: [Int]
let templateChat: DcChat?

private var changeGroupImage: UIImage?
private var deleteGroupImage: Bool = false
Expand Down Expand Up @@ -55,7 +56,7 @@ class NewGroupController: UITableViewController, MediaPickerDelegate {
return cell
}()

init(dcContext: DcContext, createBroadcast: Bool) {
init(dcContext: DcContext, createBroadcast: Bool, templateChatId: Int? = nil) {
self.createBroadcast = createBroadcast
self.dcContext = dcContext
self.sections = [.details, .invite, .members]
Expand All @@ -68,6 +69,14 @@ class NewGroupController: UITableViewController, MediaPickerDelegate {
self.inviteRows = [.addMembers]
self.contactIdsForGroup = [Int(DC_CONTACT_ID_SELF)]
}
if let templateChatId = templateChatId {
templateChat = dcContext.getChat(chatId: templateChatId)
if let templateChat = templateChat {
self.contactIdsForGroup = Set(templateChat.getContactIds(dcContext))
}
} else {
templateChat = nil
}
self.groupContactIds = Array(contactIdsForGroup)
super.init(style: .grouped)
}
Expand All @@ -83,6 +92,9 @@ class NewGroupController: UITableViewController, MediaPickerDelegate {
} else {
title = String.localized("menu_new_group")
}
if let templateChat = self.templateChat {
groupNameCell.textField.text = templateChat.name
}
doneButton = UIBarButtonItem(title: String.localized("create"), style: .done, target: self, action: #selector(doneButtonPressed))
navigationItem.rightBarButtonItem = doneButton
tableView.register(ContactCell.self, forCellReuseIdentifier: "contactCell")
Expand Down

0 comments on commit 88ea3df

Please sign in to comment.