diff --git a/ElementX/Sources/Screens/RoomScreen/View/TimelineItemMenu.swift b/ElementX/Sources/Screens/RoomScreen/View/TimelineItemMenu.swift index 18090a796..3871702ef 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/TimelineItemMenu.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/TimelineItemMenu.swift @@ -64,7 +64,7 @@ enum TimelineItemMenuAction: Identifiable, Hashable { var canAppearInFailedEcho: Bool { switch self { - case .copy, .redact, .viewSource: + case .copy, .edit, .redact, .viewSource: return true default: return false diff --git a/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineController.swift b/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineController.swift index ecc0da028..52237f39c 100644 --- a/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineController.swift +++ b/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineController.swift @@ -151,11 +151,20 @@ class RoomTimelineController: RoomTimelineControllerProtocol { func editMessage(_ newMessage: String, original itemID: String) async { MXLog.info("Edit message in \(roomID)") - switch await roomProxy.editMessage(newMessage, original: itemID) { - case .success: - MXLog.info("Finished editing message") - case .failure(let error): - MXLog.error("Failed editing message with error: \(error)") + 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) { + case .success: + MXLog.info("Finished editing message") + case .failure(let error): + MXLog.error("Failed editing message with error: \(error)") + } } } diff --git a/changelog.d/pr-1207.change b/changelog.d/pr-1207.change new file mode 100644 index 000000000..8fa818483 --- /dev/null +++ b/changelog.d/pr-1207.change @@ -0,0 +1 @@ +Failed local echoes can be edited, they will just get cancelled and resent with the new content. \ No newline at end of file