Fix #5636 - Clear the composer after editing a message or caption

This commit is contained in:
Stefan Ceriu
2026-05-26 13:20:57 +03:00
parent 72002f408d
commit a89445edae
4 changed files with 13 additions and 11 deletions
@@ -79,7 +79,7 @@ class RoomPollsHistoryScreenViewModel: RoomPollsHistoryScreenViewModelType, Room
if self.state.canBackPaginate != canBackPaginate { if self.state.canBackPaginate != canBackPaginate {
self.state.canBackPaginate = canBackPaginate self.state.canBackPaginate = canBackPaginate
} }
case .isLive, .sentMessage: case .isLive, .messageSentOrEdited:
break break
} }
} }
@@ -472,7 +472,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
state.timelineState.focussedEvent = nil state.timelineState.focussedEvent = nil
} }
} }
case .sentMessage: case .messageSentOrEdited:
actionsSubject.send(.composer(action: .clear)) actionsSubject.send(.composer(action: .clear))
} }
} }
@@ -171,6 +171,7 @@ class TimelineController: TimelineControllerProtocol {
switch await activeTimeline.edit(eventOrTransactionID, newContent: .roomMessage(content: messageContent)) { switch await activeTimeline.edit(eventOrTransactionID, newContent: .roomMessage(content: messageContent)) {
case .success: case .success:
MXLog.info("Finished editing message by event") MXLog.info("Finished editing message by event")
callbacks.send(.messageSentOrEdited)
case let .failure(error): case let .failure(error):
MXLog.error("Failed editing message by event with error: \(error)") MXLog.error("Failed editing message by event with error: \(error)")
} }
@@ -188,6 +189,7 @@ class TimelineController: TimelineControllerProtocol {
mentions: intentionalMentions.toRustMentions()) mentions: intentionalMentions.toRustMentions())
switch await activeTimeline.edit(eventOrTransactionID, newContent: newContent) { switch await activeTimeline.edit(eventOrTransactionID, newContent: newContent) {
case .success: case .success:
callbacks.send(.messageSentOrEdited)
MXLog.info("Finished editing caption") MXLog.info("Finished editing caption")
case let .failure(error): case let .failure(error):
MXLog.error("Failed editing caption with error: \(error)") MXLog.error("Failed editing caption with error: \(error)")
@@ -296,7 +298,7 @@ class TimelineController: TimelineControllerProtocol {
intentionalMentions: intentionalMentions) { intentionalMentions: intentionalMentions) {
case .success: case .success:
MXLog.info("Finished sending message") MXLog.info("Finished sending message")
callbacks.send(.sentMessage) callbacks.send(.messageSentOrEdited)
await donateSendMessageIntent() await donateSendMessageIntent()
case .failure(let error): case .failure(let error):
MXLog.error("Failed sending message with error: \(error)") MXLog.error("Failed sending message with error: \(error)")
@@ -312,7 +314,7 @@ class TimelineController: TimelineControllerProtocol {
caption: caption, caption: caption,
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError) { requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError) {
case .success: case .success:
callbacks.send(.sentMessage) callbacks.send(.messageSentOrEdited)
return .success(()) return .success(())
case .failure(let error): case .failure(let error):
return .failure(error) return .failure(error)
@@ -328,7 +330,7 @@ class TimelineController: TimelineControllerProtocol {
caption: caption, caption: caption,
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError) { requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError) {
case .success: case .success:
callbacks.send(.sentMessage) callbacks.send(.messageSentOrEdited)
return .success(()) return .success(())
case .failure(let error): case .failure(let error):
return .failure(error) return .failure(error)
@@ -346,7 +348,7 @@ class TimelineController: TimelineControllerProtocol {
caption: caption, caption: caption,
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError) { requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError) {
case .success: case .success:
callbacks.send(.sentMessage) callbacks.send(.messageSentOrEdited)
return .success(()) return .success(())
case .failure(let error): case .failure(let error):
return .failure(error) return .failure(error)
@@ -364,7 +366,7 @@ class TimelineController: TimelineControllerProtocol {
caption: caption, caption: caption,
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError) { requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError) {
case .success: case .success:
callbacks.send(.sentMessage) callbacks.send(.messageSentOrEdited)
return .success(()) return .success(())
case .failure(let error): case .failure(let error):
return .failure(error) return .failure(error)
@@ -378,7 +380,7 @@ class TimelineController: TimelineControllerProtocol {
assetType: AssetType?) async -> Result<Void, TimelineControllerError> { assetType: AssetType?) async -> Result<Void, TimelineControllerError> {
switch await activeTimeline.sendLocation(body: body, geoURI: geoURI, description: description, zoomLevel: zoomLevel, assetType: assetType).mapError(TimelineControllerError.timelineProxyError) { switch await activeTimeline.sendLocation(body: body, geoURI: geoURI, description: description, zoomLevel: zoomLevel, assetType: assetType).mapError(TimelineControllerError.timelineProxyError) {
case .success: case .success:
callbacks.send(.sentMessage) callbacks.send(.messageSentOrEdited)
return .success(()) return .success(())
case .failure(let error): case .failure(let error):
return .failure(error) return .failure(error)
@@ -393,7 +395,7 @@ class TimelineController: TimelineControllerProtocol {
audioInfo: audioInfo, audioInfo: audioInfo,
waveform: waveform, requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError) { waveform: waveform, requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError) {
case .success: case .success:
callbacks.send(.sentMessage) callbacks.send(.messageSentOrEdited)
return .success(()) return .success(())
case .failure(let error): case .failure(let error):
return .failure(error) return .failure(error)
@@ -405,7 +407,7 @@ class TimelineController: TimelineControllerProtocol {
func createPoll(question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, TimelineControllerError> { func createPoll(question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, TimelineControllerError> {
switch await activeTimeline.createPoll(question: question, answers: answers, pollKind: pollKind).mapError(TimelineControllerError.timelineProxyError) { switch await activeTimeline.createPoll(question: question, answers: answers, pollKind: pollKind).mapError(TimelineControllerError.timelineProxyError) {
case .success: case .success:
callbacks.send(.sentMessage) callbacks.send(.messageSentOrEdited)
return .success(()) return .success(())
case .failure(let error): case .failure(let error):
return .failure(error) return .failure(error)
@@ -14,7 +14,7 @@ enum TimelineControllerCallback {
case updatedTimelineItems(timelineItems: [RoomTimelineItemProtocol], isSwitchingTimelines: Bool) case updatedTimelineItems(timelineItems: [RoomTimelineItemProtocol], isSwitchingTimelines: Bool)
case paginationState(TimelinePaginationState) case paginationState(TimelinePaginationState)
case isLive(Bool) case isLive(Bool)
case sentMessage case messageSentOrEdited
} }
enum TimelineControllerAction { enum TimelineControllerAction {