Show the failure alert even when no send handle is available

This commit is contained in:
Stefan Ceriu
2026-08-18 11:15:14 +03:00
parent 28966c8397
commit 64076c6cf9
2 changed files with 10 additions and 12 deletions
@@ -222,7 +222,7 @@ struct ReadReceiptSummaryInfo: Identifiable {
enum TimelineAlertInfoType: Hashable { enum TimelineAlertInfoType: Hashable {
case audioRecodingPermissionError case audioRecodingPermissionError
case pollEndConfirmation(String) case pollEndConfirmation(String)
case sendingFailed(reason: String?, sendHandle: SendHandleProxy) case sendingFailed(reason: String?, sendHandle: SendHandleProxy?)
case encryptionAuthenticity(String) case encryptionAuthenticity(String)
case encryptionForwarder(String) case encryptionForwarder(String)
case inviteAgain case inviteAgain
@@ -739,12 +739,8 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
} }
if case let .sendingFailed(.unknown(reason)) = eventTimelineItem.properties.deliveryStatus { if case let .sendingFailed(.unknown(reason)) = eventTimelineItem.properties.deliveryStatus {
guard let sendHandle = timelineController.sendHandle(for: itemID) else { // A missing send handle only costs the retry/remove actions, the reason is still worth showing.
MXLog.error("Cannot find send handle for \(itemID).") displayAlert(.sendingFailed(reason: reason, sendHandle: timelineController.sendHandle(for: itemID)))
return
}
displayAlert(.sendingFailed(reason: reason, sendHandle: sendHandle))
} else if case let .sendingFailed(.verifiedUser(failure)) = eventTimelineItem.properties.deliveryStatus { } else if case let .sendingFailed(.verifiedUser(failure)) = eventTimelineItem.properties.deliveryStatus {
guard let sendHandle = timelineController.sendHandle(for: itemID) else { guard let sendHandle = timelineController.sendHandle(for: itemID) else {
MXLog.error("Cannot find send handle for \(itemID).") MXLog.error("Cannot find send handle for \(itemID).")
@@ -1121,11 +1117,13 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
state.bindings.alertInfo = .init(id: type, state.bindings.alertInfo = .init(id: type,
title: L10n.commonSendingFailed, title: L10n.commonSendingFailed,
message: reason, message: reason,
primaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil), primaryButton: .init(title: sendHandle == nil ? L10n.actionOk : L10n.actionCancel, role: .cancel, action: nil),
verticalButtons: [.init(title: L10n.actionRetry) { [weak self] in self?.retrySending(sendHandle) }, verticalButtons: sendHandle.map { sendHandle in
.init(title: L10n.actionRemoveMessage, role: .destructive) { [weak self] in [.init(title: L10n.actionRetry) { [weak self] in self?.retrySending(sendHandle) },
self?.timelineInteractionHandler.handleTimelineItemMenuAction(.redact(isMedia: false), itemID: sendHandle.itemID) .init(title: L10n.actionRemoveMessage, role: .destructive) { [weak self] in
}]) self?.timelineInteractionHandler.handleTimelineItemMenuAction(.redact(isMedia: false), itemID: sendHandle.itemID)
}]
})
case .encryptionAuthenticity(let message): case .encryptionAuthenticity(let message):
state.bindings.alertInfo = .init(id: type, state.bindings.alertInfo = .init(id: type,
title: message, title: message,