mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 20:09:04 +00:00
Improve how the composer is cleared after sending a message.
This commit is contained in:
+1
-1
@@ -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:
|
case .isLive, .sentMessage:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -472,6 +472,8 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
|||||||
state.timelineState.focussedEvent = nil
|
state.timelineState.focussedEvent = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case .sentMessage:
|
||||||
|
actionsSubject.send(.composer(action: .clear))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
@@ -764,8 +766,6 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
|||||||
fatalError("This message should never be empty")
|
fatalError("This message should never be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
actionsSubject.send(.composer(action: .clear))
|
|
||||||
|
|
||||||
switch mode {
|
switch mode {
|
||||||
case .reply(let eventID, _, _):
|
case .reply(let eventID, _, _):
|
||||||
await timelineController.sendMessage(message,
|
await timelineController.sendMessage(message,
|
||||||
|
|||||||
@@ -296,6 +296,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)
|
||||||
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)")
|
||||||
@@ -306,20 +307,32 @@ class TimelineController: TimelineControllerProtocol {
|
|||||||
audioInfo: MatrixRustSDK.AudioInfo,
|
audioInfo: MatrixRustSDK.AudioInfo,
|
||||||
caption: String?,
|
caption: String?,
|
||||||
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
|
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
|
||||||
await activeTimeline.sendAudio(url: url,
|
switch await activeTimeline.sendAudio(url: url,
|
||||||
audioInfo: audioInfo,
|
audioInfo: audioInfo,
|
||||||
caption: caption,
|
caption: caption,
|
||||||
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError)
|
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError) {
|
||||||
|
case .success:
|
||||||
|
callbacks.send(.sentMessage)
|
||||||
|
return .success(())
|
||||||
|
case .failure(let error):
|
||||||
|
return .failure(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendFile(url: URL,
|
func sendFile(url: URL,
|
||||||
fileInfo: MatrixRustSDK.FileInfo,
|
fileInfo: MatrixRustSDK.FileInfo,
|
||||||
caption: String?,
|
caption: String?,
|
||||||
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
|
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
|
||||||
await activeTimeline.sendFile(url: url,
|
switch await activeTimeline.sendFile(url: url,
|
||||||
fileInfo: fileInfo,
|
fileInfo: fileInfo,
|
||||||
caption: caption,
|
caption: caption,
|
||||||
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError)
|
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError) {
|
||||||
|
case .success:
|
||||||
|
callbacks.send(.sentMessage)
|
||||||
|
return .success(())
|
||||||
|
case .failure(let error):
|
||||||
|
return .failure(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendImage(url: URL,
|
func sendImage(url: URL,
|
||||||
@@ -327,11 +340,17 @@ class TimelineController: TimelineControllerProtocol {
|
|||||||
imageInfo: MatrixRustSDK.ImageInfo,
|
imageInfo: MatrixRustSDK.ImageInfo,
|
||||||
caption: String?,
|
caption: String?,
|
||||||
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
|
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
|
||||||
await activeTimeline.sendImage(url: url,
|
switch await activeTimeline.sendImage(url: url,
|
||||||
thumbnailURL: thumbnailURL,
|
thumbnailURL: thumbnailURL,
|
||||||
imageInfo: imageInfo,
|
imageInfo: imageInfo,
|
||||||
caption: caption,
|
caption: caption,
|
||||||
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError)
|
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError) {
|
||||||
|
case .success:
|
||||||
|
callbacks.send(.sentMessage)
|
||||||
|
return .success(())
|
||||||
|
case .failure(let error):
|
||||||
|
return .failure(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendVideo(url: URL,
|
func sendVideo(url: URL,
|
||||||
@@ -339,11 +358,17 @@ class TimelineController: TimelineControllerProtocol {
|
|||||||
videoInfo: MatrixRustSDK.VideoInfo,
|
videoInfo: MatrixRustSDK.VideoInfo,
|
||||||
caption: String?,
|
caption: String?,
|
||||||
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
|
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
|
||||||
await activeTimeline.sendVideo(url: url,
|
switch await activeTimeline.sendVideo(url: url,
|
||||||
thumbnailURL: thumbnailURL,
|
thumbnailURL: thumbnailURL,
|
||||||
videoInfo: videoInfo,
|
videoInfo: videoInfo,
|
||||||
caption: caption,
|
caption: caption,
|
||||||
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError)
|
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError) {
|
||||||
|
case .success:
|
||||||
|
callbacks.send(.sentMessage)
|
||||||
|
return .success(())
|
||||||
|
case .failure(let error):
|
||||||
|
return .failure(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendLocation(body: String,
|
func sendLocation(body: String,
|
||||||
@@ -351,22 +376,40 @@ class TimelineController: TimelineControllerProtocol {
|
|||||||
description: String?,
|
description: String?,
|
||||||
zoomLevel: UInt8?,
|
zoomLevel: UInt8?,
|
||||||
assetType: AssetType?) async -> Result<Void, TimelineControllerError> {
|
assetType: AssetType?) async -> Result<Void, TimelineControllerError> {
|
||||||
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:
|
||||||
|
callbacks.send(.sentMessage)
|
||||||
|
return .success(())
|
||||||
|
case .failure(let error):
|
||||||
|
return .failure(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendVoiceMessage(url: URL,
|
func sendVoiceMessage(url: URL,
|
||||||
audioInfo: MatrixRustSDK.AudioInfo,
|
audioInfo: MatrixRustSDK.AudioInfo,
|
||||||
waveform: [Float],
|
waveform: [Float],
|
||||||
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
|
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
|
||||||
await activeTimeline.sendVoiceMessage(url: url,
|
switch await activeTimeline.sendVoiceMessage(url: url,
|
||||||
audioInfo: audioInfo,
|
audioInfo: audioInfo,
|
||||||
waveform: waveform, requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError)
|
waveform: waveform, requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError) {
|
||||||
|
case .success:
|
||||||
|
callbacks.send(.sentMessage)
|
||||||
|
return .success(())
|
||||||
|
case .failure(let error):
|
||||||
|
return .failure(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Polls
|
// MARK: - Polls
|
||||||
|
|
||||||
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> {
|
||||||
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:
|
||||||
|
callbacks.send(.sentMessage)
|
||||||
|
return .success(())
|
||||||
|
case .failure(let error):
|
||||||
|
return .failure(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func editPoll(original eventID: String, question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, TimelineControllerError> {
|
func editPoll(original eventID: String, question: String, answers: [String], pollKind: Poll.Kind) async -> Result<Void, TimelineControllerError> {
|
||||||
|
|||||||
@@ -14,6 +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
|
||||||
}
|
}
|
||||||
|
|
||||||
enum TimelineControllerAction {
|
enum TimelineControllerAction {
|
||||||
|
|||||||
Reference in New Issue
Block a user