mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
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:
@@ -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,11 +151,20 @@ 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)")
|
||||||
switch await roomProxy.editMessage(newMessage, original: itemID) {
|
if let timelineItem = timelineItems.first(where: { $0.id == itemID }),
|
||||||
case .success:
|
let item = timelineItem as? EventBasedTimelineItemProtocol,
|
||||||
MXLog.info("Finished editing message")
|
item.hasFailedToSend,
|
||||||
case .failure(let error):
|
let transactionID = item.properties.transactionID {
|
||||||
MXLog.error("Failed editing message with error: \(error)")
|
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)")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Failed local echoes can be edited, they will just get cancelled and resent with the new content.
|
||||||
Reference in New Issue
Block a user