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
@@ -96,11 +96,11 @@ final class TimelineProxy: TimelineProxyProtocol {
}
func editMessage(_ message: String,
html: String,
html: String?,
original eventID: String,
intentionalMentions: IntentionalMentions) async -> Result<Void, TimelineProxyError> {
MXLog.info("Editing message with original event ID: \(eventID)")
sendMessageBackgroundTask = await backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true)
defer {
sendMessageBackgroundTask?.stop()
@@ -390,7 +390,7 @@ final class TimelineProxy: TimelineProxyProtocol {
}
func sendMessage(_ message: String,
html: String,
html: String?,
inReplyTo eventID: String? = nil,
intentionalMentions: IntentionalMentions) async -> Result<Void, TimelineProxyError> {
if let eventID {
@@ -573,7 +573,7 @@ final class TimelineProxy: TimelineProxyProtocol {
// MARK: - Private
private func buildMessageContentFor(_ message: String,
html: String,
html: String?,
intentionalMentions: Mentions) -> RoomMessageEventContentWithoutRelation {
let emoteSlashCommand = "/me "
let isEmote: Bool = message.starts(with: emoteSlashCommand)
@@ -581,10 +581,18 @@ final class TimelineProxy: TimelineProxyProtocol {
let content: RoomMessageEventContentWithoutRelation
if isEmote {
let emoteMessage = String(message.dropFirst(emoteSlashCommand.count))
let emoteHtml = String(html.dropFirst(emoteSlashCommand.count))
var emoteHtml: String?
if let html {
emoteHtml = String(html.dropFirst(emoteSlashCommand.count))
}
content = buildEmoteMessageContentFor(emoteMessage, html: emoteHtml)
} else {
content = messageEventContentFromHtml(body: message, htmlBody: html)
if let html {
content = messageEventContentFromHtml(body: message, htmlBody: html)
} else {
content = messageEventContentFromMarkdown(md: message)
}
}
return content.withMentions(mentions: intentionalMentions)
}