FIX: saving draft did not save the pill markdown content (#3003)

This commit is contained in:
Mauro
2024-07-08 15:55:13 +02:00
committed by GitHub
parent 74a078b871
commit b07d85cd06
@@ -310,7 +310,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
} }
return return
} }
plainText = context.plainComposerText.string plainText = plainComposerContent.text
htmlText = nil htmlText = nil
} }
@@ -349,7 +349,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
} }
} }
private func sendPlainComposerText() { private var plainComposerContent: PlainComposerContent {
let attributedString = NSMutableAttributedString(attributedString: context.plainComposerText) let attributedString = NSMutableAttributedString(attributedString: context.plainComposerText)
var shouldMakeAnotherPass = false var shouldMakeAnotherPass = false
@@ -396,9 +396,14 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
} }
} while shouldMakeAnotherPass } 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, mode: state.composerMode,
intentionalMentions: .init(userIDs: userIDs, atRoom: containsAtRoom))) intentionalMentions: .init(userIDs: plainComposerContent.mentionedUserIDs, atRoom: plainComposerContent.containsAtRoomMention)))
} }
private func processVoiceMessageAction(_ action: ComposerToolbarVoiceMessageAction) { private func processVoiceMessageAction(_ action: ComposerToolbarVoiceMessageAction) {
@@ -658,3 +663,9 @@ private final class ComposerMentionReplacer: MentionReplacer {
replacementForMentionClosure(url, text) replacementForMentionClosure(url, text)
} }
} }
private struct PlainComposerContent {
let text: String
let mentionedUserIDs: Set<String>
let containsAtRoomMention: Bool
}