Prevent invalid composer mode crashes

Cause by voice recording racing against the send action.
This commit is contained in:
Stefan Ceriu
2026-08-13 10:35:18 +03:00
parent d4d74dd8f8
commit b41d801cab
2 changed files with 4 additions and 1 deletions
@@ -189,6 +189,8 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
switch state.composerMode { switch state.composerMode {
case .previewVoiceMessage: case .previewVoiceMessage:
actionsSubject.send(.voiceMessage(.send)) actionsSubject.send(.voiceMessage(.send))
case .recordVoiceMessage:
MXLog.warning("Ignoring send action while recording a voice message.")
default: default:
if context.composerFormattingEnabled { if context.composerFormattingEnabled {
actionsSubject.send(.sendMessage(plain: wysiwygViewModel.content.markdown, actionsSubject.send(.sendMessage(plain: wysiwygViewModel.content.markdown,
@@ -807,7 +807,8 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
intentionalMentions: intentionalMentions) intentionalMentions: intentionalMentions)
} }
case .recordVoiceMessage, .previewVoiceMessage: case .recordVoiceMessage, .previewVoiceMessage:
fatalError("invalid composer mode.") MXLog.error("Ignoring sendCurrentMessage with invalid composer mode: \(mode)")
return
} }
scrollToBottom() scrollToBottom()