diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift index 72a7b265a..4ed1910fa 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift @@ -310,7 +310,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool } return } - plainText = context.plainComposerText.string + plainText = plainComposerContent.text htmlText = nil } @@ -349,7 +349,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool } } - private func sendPlainComposerText() { + private var plainComposerContent: PlainComposerContent { let attributedString = NSMutableAttributedString(attributedString: context.plainComposerText) var shouldMakeAnotherPass = false @@ -396,9 +396,14 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool } } while shouldMakeAnotherPass - actionsSubject.send(.sendMessage(plain: attributedString.string, html: nil, + return .init(text: attributedString.string, mentionedUserIDs: userIDs, containsAtRoomMention: containsAtRoom) + } + + private func sendPlainComposerText() { + let plainComposerContent = plainComposerContent + actionsSubject.send(.sendMessage(plain: plainComposerContent.text, html: nil, mode: state.composerMode, - intentionalMentions: .init(userIDs: userIDs, atRoom: containsAtRoom))) + intentionalMentions: .init(userIDs: plainComposerContent.mentionedUserIDs, atRoom: plainComposerContent.containsAtRoomMention))) } private func processVoiceMessageAction(_ action: ComposerToolbarVoiceMessageAction) { @@ -658,3 +663,9 @@ private final class ComposerMentionReplacer: MentionReplacer { replacementForMentionClosure(url, text) } } + +private struct PlainComposerContent { + let text: String + let mentionedUserIDs: Set + let containsAtRoomMention: Bool +}