Reverting RTE to use SDK markdown when in markdown mode (#2327)

This commit is contained in:
Mauro
2024-01-12 12:58:36 +01:00
committed by GitHub
parent 2d66e76b51
commit 1001b5dc33
13 changed files with 76 additions and 32 deletions
@@ -31,7 +31,7 @@ enum ComposerToolbarVoiceMessageAction {
}
enum ComposerToolbarViewModelAction {
case sendMessage(plain: String, html: String, mode: RoomScreenComposerMode, intentionalMentions: IntentionalMentions)
case sendMessage(plain: String, html: String?, mode: RoomScreenComposerMode, intentionalMentions: IntentionalMentions)
case attach(ComposerAttachmentType)
case handlePasteOrDrop(provider: NSItemProvider)
@@ -87,11 +87,15 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
}
.store(in: &cancellables)
appSettings.$richTextEditorEnabled
.map { !$0 }
.assign(to: &wysiwygViewModel.$plainTextMode)
completionSuggestionService.suggestionsPublisher
.combineLatest(appSettings.$richTextEditorEnabled)
.map { suggestions, richTextEditorEnabled in
// We ignore user suggestions when RTE is disabled since mentions would not work
guard richTextEditorEnabled else {
return []
}
return suggestions
}
.weakAssign(to: \.state.suggestions, on: self)
.store(in: &cancellables)
@@ -111,8 +115,9 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
case .previewVoiceMessage:
actionsSubject.send(.voiceMessage(.send))
default:
let sendHTML = appSettings.richTextEditorEnabled
actionsSubject.send(.sendMessage(plain: wysiwygViewModel.content.markdown,
html: wysiwygViewModel.content.html,
html: sendHTML ? wysiwygViewModel.content.html : nil,
mode: state.composerMode,
intentionalMentions: wysiwygViewModel
.getMentionsState()
@@ -461,7 +461,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
state.showLoading = false
}
private func sendCurrentMessage(_ message: String, html: String, mode: RoomScreenComposerMode, intentionalMentions: IntentionalMentions) async {
private func sendCurrentMessage(_ message: String, html: String?, mode: RoomScreenComposerMode, intentionalMentions: IntentionalMentions) async {
guard !message.isEmpty else {
fatalError("This message should never be empty")
}