Editing a failed echo, just cancels and resends it (#1207)

* editing a failed message means cancelling and resending it

* changelog
This commit is contained in:
Mauro
2023-06-29 16:37:52 +02:00
committed by GitHub
parent 3a6876f385
commit b2ab6103c3
3 changed files with 16 additions and 6 deletions
@@ -64,7 +64,7 @@ enum TimelineItemMenuAction: Identifiable, Hashable {
var canAppearInFailedEcho: Bool { var canAppearInFailedEcho: Bool {
switch self { switch self {
case .copy, .redact, .viewSource: case .copy, .edit, .redact, .viewSource:
return true return true
default: default:
return false return false
@@ -151,6 +151,14 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
func editMessage(_ newMessage: String, original itemID: String) async { func editMessage(_ newMessage: String, original itemID: String) async {
MXLog.info("Edit message in \(roomID)") MXLog.info("Edit message in \(roomID)")
if let timelineItem = timelineItems.first(where: { $0.id == itemID }),
let item = timelineItem as? EventBasedTimelineItemProtocol,
item.hasFailedToSend,
let transactionID = item.properties.transactionID {
MXLog.info("Editing a failed echo, will cancel and resend it as a new message")
await cancelSend(transactionID)
await sendMessage(newMessage)
} else {
switch await roomProxy.editMessage(newMessage, original: itemID) { switch await roomProxy.editMessage(newMessage, original: itemID) {
case .success: case .success:
MXLog.info("Finished editing message") MXLog.info("Finished editing message")
@@ -158,6 +166,7 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
MXLog.error("Failed editing message with error: \(error)") MXLog.error("Failed editing message with error: \(error)")
} }
} }
}
func redact(_ itemID: String) async { func redact(_ itemID: String) async {
MXLog.info("Send redaction in \(roomID)") MXLog.info("Send redaction in \(roomID)")
+1
View File
@@ -0,0 +1 @@
Failed local echoes can be edited, they will just get cancelled and resent with the new content.