Skip to content

Commit

Permalink
fix & tweak forwarding (#2607)
Browse files Browse the repository at this point in the history
* simplify code

* simplify forward button wording and let it fit to singular/plural

* let caller decide if to pass an emtpy array

this does not make sense,
however, would also not be worse than having RelayHelper setup half.
(we leave checking also for empty text etc. up to the caller)

* make sure, chat list is filtered accordingly on forwarding

* do not start in 'archive' when selecting forwarding destination

* cancelling message-forwarding ends out in the original chat

* treat 'forwarding to self' as usual

meanwhile, we have an explicit shortcut,
so it seems reasonable to not differ otherwise for a now rarely used function.

* update CHANGELOG
  • Loading branch information
r10s authored Feb 13, 2025
1 parent 328e6e7 commit acda53c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 28 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

- Share files generated by webxdc apps directly (#2606)
- Tweak menu order (#2604)
- Fix: Hide read-only chats on forwarding and sort list accordingly (#2436)
- Fix: Let 'Cancel' work as expecting when forwarding messages (#2436)
- Fix: Preserve filenames on sharing (#2605)


Expand Down
35 changes: 16 additions & 19 deletions deltachat-ios/Chat/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1307,21 +1307,16 @@ class ChatViewController: UITableViewController, UITableViewDropDelegate {

private func askToForwardMessage() {
let chat = dcContext.getChat(chatId: chatId)
if chat.isSelfTalk {
RelayHelper.shared.forwardIdsAndFinishRelaying(to: chatId)
refreshMessages()
} else {
confirmationAlert(title: String.localizedStringWithFormat(String.localized("ask_forward"), chat.name),
actionTitle: String.localized("menu_forward"),
actionHandler: { [weak self] _ in
guard let self else { return }
RelayHelper.shared.forwardIdsAndFinishRelaying(to: self.chatId)
self.becomeFirstResponder()
},
cancelHandler: { [weak self] _ in
self?.navigationController?.popViewController(animated: true)
})
}
confirmationAlert(title: String.localizedStringWithFormat(String.localized("ask_forward"), chat.name),
actionTitle: String.localized("forward"),
actionHandler: { [weak self] _ in
guard let self else { return }
RelayHelper.shared.forwardIdsAndFinishRelaying(to: chatId)
becomeFirstResponder()
},
cancelHandler: { [weak self] _ in
self?.navigationController?.popViewController(animated: true)
})
}

// MARK: - coordinator
Expand Down Expand Up @@ -1662,8 +1657,8 @@ class ChatViewController: UITableViewController, UITableViewDropDelegate {

private func forward(at indexPath: IndexPath) {
let msg = dcContext.getMessage(id: messageIds[indexPath.row])
RelayHelper.shared.setForwardMessage(messageId: msg.id)
navigationController?.popViewController(animated: true)
RelayHelper.shared.setForwardMessages(messageIds: [msg.id])
navigationController?.popToRootViewController(animated: true)
}

private func reply(at indexPath: IndexPath) {
Expand Down Expand Up @@ -2452,8 +2447,10 @@ extension ChatViewController: ChatEditingDelegate {
func onForwardPressed() {
if let rows = tableView.indexPathsForSelectedRows {
let messageIdsToForward = rows.compactMap { messageIds[$0.row] }
RelayHelper.shared.setForwardMessages(messageIds: messageIdsToForward)
self.navigationController?.popViewController(animated: true)
if !messageIdsToForward.isEmpty {
RelayHelper.shared.setForwardMessages(messageIds: messageIdsToForward)
self.navigationController?.popToRootViewController(animated: true)
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions deltachat-ios/Controller/ChatListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class ChatListViewController: UITableViewController {
updateTitle()

if RelayHelper.shared.isForwarding() {
refreshInBg()
quitSearch(animated: false)
tableView.scrollToTop()
}
Expand Down Expand Up @@ -371,9 +372,13 @@ class ChatListViewController: UITableViewController {
if tableView.isEditing {
self.setLongTapEditing(false)
} else {
let returnToMsgId = RelayHelper.shared.forwardIds?.first
RelayHelper.shared.finishRelaying()
updateTitle()
refreshInBg()
if let returnToMsgId {
showChat(chatId: dcContext.getMessage(id: returnToMsgId).chatId, highlightedMsg: returnToMsgId)
}
}
}

Expand Down
10 changes: 1 addition & 9 deletions deltachat-ios/Helper/RelayHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,10 @@ class RelayHelper {
self.forwardFileName = fileName
}

func setForwardMessage(messageId: Int) {
finishRelaying()
self.dialogTitle = String.localized("forward_to")
self.forwardIds = [messageId]
}

func setForwardMessages(messageIds: [Int]) {
finishRelaying()
self.dialogTitle = String.localized("forward_to")
if !messageIds.isEmpty {
self.forwardIds = messageIds
}
self.forwardIds = messageIds
}

func isForwarding() -> Bool {
Expand Down

0 comments on commit acda53c

Please sign in to comment.