mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Send Intentional Mentions (#1929)
* updated sdks * fix waveform * implementation completed * intentional mentions test * removed unused var * suggestion
This commit is contained in:
@@ -249,7 +249,9 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
|
||||
return
|
||||
}
|
||||
let roomProxy = await userSession.clientProxy.roomForIdentifier(roomID)
|
||||
switch await roomProxy?.sendMessage(replyText, html: nil) {
|
||||
switch await roomProxy?.sendMessage(replyText,
|
||||
html: nil,
|
||||
intentionalMentions: .empty) {
|
||||
case .success:
|
||||
break
|
||||
default:
|
||||
|
||||
@@ -1625,23 +1625,23 @@ class RoomProxyMock: RoomProxyProtocol {
|
||||
}
|
||||
//MARK: - sendMessage
|
||||
|
||||
var sendMessageHtmlInReplyToCallsCount = 0
|
||||
var sendMessageHtmlInReplyToCalled: Bool {
|
||||
return sendMessageHtmlInReplyToCallsCount > 0
|
||||
var sendMessageHtmlInReplyToIntentionalMentionsCallsCount = 0
|
||||
var sendMessageHtmlInReplyToIntentionalMentionsCalled: Bool {
|
||||
return sendMessageHtmlInReplyToIntentionalMentionsCallsCount > 0
|
||||
}
|
||||
var sendMessageHtmlInReplyToReceivedArguments: (message: String, html: String?, eventID: String?)?
|
||||
var sendMessageHtmlInReplyToReceivedInvocations: [(message: String, html: String?, eventID: String?)] = []
|
||||
var sendMessageHtmlInReplyToReturnValue: Result<Void, RoomProxyError>!
|
||||
var sendMessageHtmlInReplyToClosure: ((String, String?, String?) async -> Result<Void, RoomProxyError>)?
|
||||
var sendMessageHtmlInReplyToIntentionalMentionsReceivedArguments: (message: String, html: String?, eventID: String?, intentionalMentions: IntentionalMentions)?
|
||||
var sendMessageHtmlInReplyToIntentionalMentionsReceivedInvocations: [(message: String, html: String?, eventID: String?, intentionalMentions: IntentionalMentions)] = []
|
||||
var sendMessageHtmlInReplyToIntentionalMentionsReturnValue: Result<Void, RoomProxyError>!
|
||||
var sendMessageHtmlInReplyToIntentionalMentionsClosure: ((String, String?, String?, IntentionalMentions) async -> Result<Void, RoomProxyError>)?
|
||||
|
||||
func sendMessage(_ message: String, html: String?, inReplyTo eventID: String?) async -> Result<Void, RoomProxyError> {
|
||||
sendMessageHtmlInReplyToCallsCount += 1
|
||||
sendMessageHtmlInReplyToReceivedArguments = (message: message, html: html, eventID: eventID)
|
||||
sendMessageHtmlInReplyToReceivedInvocations.append((message: message, html: html, eventID: eventID))
|
||||
if let sendMessageHtmlInReplyToClosure = sendMessageHtmlInReplyToClosure {
|
||||
return await sendMessageHtmlInReplyToClosure(message, html, eventID)
|
||||
func sendMessage(_ message: String, html: String?, inReplyTo eventID: String?, intentionalMentions: IntentionalMentions) async -> Result<Void, RoomProxyError> {
|
||||
sendMessageHtmlInReplyToIntentionalMentionsCallsCount += 1
|
||||
sendMessageHtmlInReplyToIntentionalMentionsReceivedArguments = (message: message, html: html, eventID: eventID, intentionalMentions: intentionalMentions)
|
||||
sendMessageHtmlInReplyToIntentionalMentionsReceivedInvocations.append((message: message, html: html, eventID: eventID, intentionalMentions: intentionalMentions))
|
||||
if let sendMessageHtmlInReplyToIntentionalMentionsClosure = sendMessageHtmlInReplyToIntentionalMentionsClosure {
|
||||
return await sendMessageHtmlInReplyToIntentionalMentionsClosure(message, html, eventID, intentionalMentions)
|
||||
} else {
|
||||
return sendMessageHtmlInReplyToReturnValue
|
||||
return sendMessageHtmlInReplyToIntentionalMentionsReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - toggleReaction
|
||||
@@ -1788,23 +1788,23 @@ class RoomProxyMock: RoomProxyProtocol {
|
||||
}
|
||||
//MARK: - editMessage
|
||||
|
||||
var editMessageHtmlOriginalCallsCount = 0
|
||||
var editMessageHtmlOriginalCalled: Bool {
|
||||
return editMessageHtmlOriginalCallsCount > 0
|
||||
var editMessageHtmlOriginalIntentionalMentionsCallsCount = 0
|
||||
var editMessageHtmlOriginalIntentionalMentionsCalled: Bool {
|
||||
return editMessageHtmlOriginalIntentionalMentionsCallsCount > 0
|
||||
}
|
||||
var editMessageHtmlOriginalReceivedArguments: (newMessage: String, html: String?, eventID: String)?
|
||||
var editMessageHtmlOriginalReceivedInvocations: [(newMessage: String, html: String?, eventID: String)] = []
|
||||
var editMessageHtmlOriginalReturnValue: Result<Void, RoomProxyError>!
|
||||
var editMessageHtmlOriginalClosure: ((String, String?, String) async -> Result<Void, RoomProxyError>)?
|
||||
var editMessageHtmlOriginalIntentionalMentionsReceivedArguments: (newMessage: String, html: String?, eventID: String, intentionalMentions: IntentionalMentions)?
|
||||
var editMessageHtmlOriginalIntentionalMentionsReceivedInvocations: [(newMessage: String, html: String?, eventID: String, intentionalMentions: IntentionalMentions)] = []
|
||||
var editMessageHtmlOriginalIntentionalMentionsReturnValue: Result<Void, RoomProxyError>!
|
||||
var editMessageHtmlOriginalIntentionalMentionsClosure: ((String, String?, String, IntentionalMentions) async -> Result<Void, RoomProxyError>)?
|
||||
|
||||
func editMessage(_ newMessage: String, html: String?, original eventID: String) async -> Result<Void, RoomProxyError> {
|
||||
editMessageHtmlOriginalCallsCount += 1
|
||||
editMessageHtmlOriginalReceivedArguments = (newMessage: newMessage, html: html, eventID: eventID)
|
||||
editMessageHtmlOriginalReceivedInvocations.append((newMessage: newMessage, html: html, eventID: eventID))
|
||||
if let editMessageHtmlOriginalClosure = editMessageHtmlOriginalClosure {
|
||||
return await editMessageHtmlOriginalClosure(newMessage, html, eventID)
|
||||
func editMessage(_ newMessage: String, html: String?, original eventID: String, intentionalMentions: IntentionalMentions) async -> Result<Void, RoomProxyError> {
|
||||
editMessageHtmlOriginalIntentionalMentionsCallsCount += 1
|
||||
editMessageHtmlOriginalIntentionalMentionsReceivedArguments = (newMessage: newMessage, html: html, eventID: eventID, intentionalMentions: intentionalMentions)
|
||||
editMessageHtmlOriginalIntentionalMentionsReceivedInvocations.append((newMessage: newMessage, html: html, eventID: eventID, intentionalMentions: intentionalMentions))
|
||||
if let editMessageHtmlOriginalIntentionalMentionsClosure = editMessageHtmlOriginalIntentionalMentionsClosure {
|
||||
return await editMessageHtmlOriginalIntentionalMentionsClosure(newMessage, html, eventID, intentionalMentions)
|
||||
} else {
|
||||
return editMessageHtmlOriginalReturnValue
|
||||
return editMessageHtmlOriginalIntentionalMentionsReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - redact
|
||||
|
||||
@@ -19,7 +19,7 @@ import UIKit
|
||||
import WysiwygComposer
|
||||
|
||||
enum ComposerToolbarViewModelAction {
|
||||
case sendMessage(plain: String, html: String?, mode: RoomScreenComposerMode)
|
||||
case sendMessage(plain: String, html: String?, mode: RoomScreenComposerMode, intentionalMentions: IntentionalMentions)
|
||||
case displayCameraPicker
|
||||
case displayMediaPicker
|
||||
case displayDocumentPicker
|
||||
|
||||
@@ -111,7 +111,10 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
|
||||
let sendHTML = ServiceLocator.shared.settings.richTextEditorEnabled
|
||||
actionsSubject.send(.sendMessage(plain: wysiwygViewModel.content.markdown,
|
||||
html: sendHTML ? wysiwygViewModel.content.html : nil,
|
||||
mode: state.composerMode))
|
||||
mode: state.composerMode,
|
||||
intentionalMentions: wysiwygViewModel
|
||||
.getMentionsState()
|
||||
.toIntentionalMentions()))
|
||||
}
|
||||
case .cancelReply:
|
||||
set(mode: .default)
|
||||
|
||||
@@ -171,8 +171,13 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
|
||||
func process(composerAction: ComposerToolbarViewModelAction) {
|
||||
switch composerAction {
|
||||
case .sendMessage(let message, let html, let mode):
|
||||
Task { await sendCurrentMessage(message, html: html, mode: mode) }
|
||||
case .sendMessage(let message, let html, let mode, let intentionalMentions):
|
||||
Task {
|
||||
await sendCurrentMessage(message,
|
||||
html: html,
|
||||
mode: mode,
|
||||
intentionalMentions: intentionalMentions)
|
||||
}
|
||||
case .displayCameraPicker:
|
||||
actionsSubject.send(.displayCameraPicker)
|
||||
case .displayMediaPicker:
|
||||
@@ -468,7 +473,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
return eventTimelineItem.properties.reactions.isEmpty && eventTimelineItem.sender == otherEventTimelineItem.sender
|
||||
}
|
||||
|
||||
private func sendCurrentMessage(_ message: String, html: String?, mode: RoomScreenComposerMode) async {
|
||||
private func sendCurrentMessage(_ message: String, html: String?, mode: RoomScreenComposerMode, intentionalMentions: IntentionalMentions) async {
|
||||
guard !message.isEmpty else {
|
||||
fatalError("This message should never be empty")
|
||||
}
|
||||
@@ -477,11 +482,19 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
|
||||
switch mode {
|
||||
case .reply(let itemId, _, _):
|
||||
await timelineController.sendMessage(message, html: html, inReplyTo: itemId)
|
||||
await timelineController.sendMessage(message,
|
||||
html: html,
|
||||
inReplyTo: itemId,
|
||||
intentionalMentions: intentionalMentions)
|
||||
case .edit(let originalItemId):
|
||||
await timelineController.editMessage(message, html: html, original: originalItemId)
|
||||
await timelineController.editMessage(message,
|
||||
html: html,
|
||||
original: originalItemId,
|
||||
intentionalMentions: intentionalMentions)
|
||||
case .default:
|
||||
await timelineController.sendMessage(message, html: html)
|
||||
await timelineController.sendMessage(message,
|
||||
html: html,
|
||||
intentionalMentions: intentionalMentions)
|
||||
case .recordVoiceMessage, .previewVoiceMessage:
|
||||
fatalError("invalid composer mode.")
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ private struct ElementCallWidgetMessage: Codable {
|
||||
}
|
||||
}
|
||||
|
||||
class ElementCallWidgetDriver: WidgetPermissionsProvider, ElementCallWidgetDriverProtocol {
|
||||
class ElementCallWidgetDriver: WidgetCapabilitiesProvider, ElementCallWidgetDriverProtocol {
|
||||
private let room: RoomProtocol
|
||||
private var widgetDriver: WidgetDriverAndHandle?
|
||||
|
||||
@@ -66,7 +66,7 @@ class ElementCallWidgetDriver: WidgetPermissionsProvider, ElementCallWidgetDrive
|
||||
appPrompt: false,
|
||||
skipLobby: true,
|
||||
confineToRoom: true,
|
||||
fonts: nil,
|
||||
font: nil,
|
||||
analyticsId: nil)) else {
|
||||
return .failure(.failedBuildingWidgetSettings)
|
||||
}
|
||||
@@ -114,7 +114,7 @@ class ElementCallWidgetDriver: WidgetPermissionsProvider, ElementCallWidgetDrive
|
||||
MXLog.debug("Stopped widget driver")
|
||||
}
|
||||
|
||||
await widgetDriver.driver.run(room: room, permissionsProvider: self)
|
||||
await widgetDriver.driver.run(room: room, capabilitiesProvider: self)
|
||||
}
|
||||
|
||||
return .success(url)
|
||||
@@ -133,10 +133,10 @@ class ElementCallWidgetDriver: WidgetPermissionsProvider, ElementCallWidgetDrive
|
||||
return .success(result)
|
||||
}
|
||||
|
||||
// MARK: - WidgetPermissionsProvider
|
||||
// MARK: - WidgetCapabilitiesProvider
|
||||
|
||||
func acquirePermissions(permissions: MatrixRustSDK.WidgetPermissions) -> MatrixRustSDK.WidgetPermissions {
|
||||
permissions
|
||||
func acquireCapabilities(capabilities: WidgetPermissions) -> WidgetPermissions {
|
||||
capabilities
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
@@ -257,13 +257,18 @@ class RoomProxy: RoomProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func sendMessage(_ message: String, html: String?, inReplyTo eventID: String? = nil) async -> Result<Void, RoomProxyError> {
|
||||
func sendMessage(_ message: String,
|
||||
html: String?,
|
||||
inReplyTo eventID: String? = nil,
|
||||
intentionalMentions: IntentionalMentions) async -> Result<Void, RoomProxyError> {
|
||||
sendMessageBackgroundTask = await backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true)
|
||||
defer {
|
||||
sendMessageBackgroundTask?.stop()
|
||||
}
|
||||
|
||||
let messageContent = buildMessageContentFor(message, html: html)
|
||||
let messageContent = buildMessageContentFor(message,
|
||||
html: html,
|
||||
intentionalMentions: intentionalMentions.toRustMentions())
|
||||
|
||||
return await Task.dispatch(on: messageSendingDispatchQueue) {
|
||||
do {
|
||||
@@ -435,13 +440,18 @@ class RoomProxy: RoomProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func editMessage(_ message: String, html: String?, original eventID: String) async -> Result<Void, RoomProxyError> {
|
||||
func editMessage(_ message: String,
|
||||
html: String?,
|
||||
original eventID: String,
|
||||
intentionalMentions: IntentionalMentions) async -> Result<Void, RoomProxyError> {
|
||||
sendMessageBackgroundTask = await backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true)
|
||||
defer {
|
||||
sendMessageBackgroundTask?.stop()
|
||||
}
|
||||
|
||||
let messageContent = buildMessageContentFor(message, html: html)
|
||||
let messageContent = buildMessageContentFor(message,
|
||||
html: html,
|
||||
intentionalMentions: intentionalMentions.toRustMentions())
|
||||
|
||||
return await Task.dispatch(on: messageSendingDispatchQueue) {
|
||||
do {
|
||||
@@ -718,26 +728,29 @@ class RoomProxy: RoomProxyProtocol {
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func buildMessageContentFor(_ message: String, html: String?) -> RoomMessageEventContentWithoutRelation {
|
||||
private func buildMessageContentFor(_ message: String,
|
||||
html: String?,
|
||||
intentionalMentions: Mentions) -> RoomMessageEventContentWithoutRelation {
|
||||
let emoteSlashCommand = "/me "
|
||||
let isEmote: Bool = message.starts(with: emoteSlashCommand)
|
||||
|
||||
guard isEmote else {
|
||||
let content: RoomMessageEventContentWithoutRelation
|
||||
if isEmote {
|
||||
let emoteMessage = String(message.dropFirst(emoteSlashCommand.count))
|
||||
|
||||
var emoteHtml: String?
|
||||
if let html {
|
||||
return messageEventContentFromHtml(body: message, htmlBody: html)
|
||||
emoteHtml = String(html.dropFirst(emoteSlashCommand.count))
|
||||
}
|
||||
content = buildEmoteMessageContentFor(emoteMessage, html: emoteHtml)
|
||||
} else {
|
||||
if let html {
|
||||
content = messageEventContentFromHtml(body: message, htmlBody: html)
|
||||
} else {
|
||||
return messageEventContentFromMarkdown(md: message)
|
||||
content = messageEventContentFromMarkdown(md: message)
|
||||
}
|
||||
}
|
||||
|
||||
let emoteMessage = String(message.dropFirst(emoteSlashCommand.count))
|
||||
|
||||
var emoteHtml: String?
|
||||
if let html {
|
||||
emoteHtml = String(html.dropFirst(emoteSlashCommand.count))
|
||||
}
|
||||
|
||||
return buildEmoteMessageContentFor(emoteMessage, html: emoteHtml)
|
||||
return content.withMentions(mentions: intentionalMentions)
|
||||
}
|
||||
|
||||
private func buildEmoteMessageContentFor(_ message: String, html: String?) -> RoomMessageEventContentWithoutRelation {
|
||||
|
||||
@@ -96,7 +96,10 @@ protocol RoomProxyProtocol {
|
||||
|
||||
func sendMessageEventContent(_ messageContent: RoomMessageEventContentWithoutRelation) async -> Result<Void, RoomProxyError>
|
||||
|
||||
func sendMessage(_ message: String, html: String?, inReplyTo eventID: String?) async -> Result<Void, RoomProxyError>
|
||||
func sendMessage(_ message: String,
|
||||
html: String?,
|
||||
inReplyTo eventID: String?,
|
||||
intentionalMentions: IntentionalMentions) async -> Result<Void, RoomProxyError>
|
||||
|
||||
func toggleReaction(_ reaction: String, to eventID: String) async -> Result<Void, RoomProxyError>
|
||||
|
||||
@@ -134,7 +137,10 @@ protocol RoomProxyProtocol {
|
||||
/// Cancels a failed message given its transaction ID from the timeline
|
||||
func cancelSend(transactionID: String) async
|
||||
|
||||
func editMessage(_ newMessage: String, html: String?, original eventID: String) async -> Result<Void, RoomProxyError>
|
||||
func editMessage(_ newMessage: String,
|
||||
html: String?,
|
||||
original eventID: String,
|
||||
intentionalMentions: IntentionalMentions) async -> Result<Void, RoomProxyError>
|
||||
|
||||
func redact(_ eventID: String) async -> Result<Void, RoomProxyError>
|
||||
|
||||
@@ -197,8 +203,13 @@ extension RoomProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func sendMessage(_ message: String, html: String?) async -> Result<Void, RoomProxyError> {
|
||||
await sendMessage(message, html: html, inReplyTo: nil)
|
||||
func sendMessage(_ message: String,
|
||||
html: String?,
|
||||
intentionalMentions: IntentionalMentions) async -> Result<Void, RoomProxyError> {
|
||||
await sendMessage(message,
|
||||
html: html,
|
||||
inReplyTo: nil,
|
||||
intentionalMentions: intentionalMentions)
|
||||
}
|
||||
|
||||
// Avoids to duplicate the same logic around in the app
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Copyright 2023 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
import MatrixRustSDK
|
||||
import WysiwygComposer
|
||||
|
||||
struct IntentionalMentions: Equatable {
|
||||
let userIDs: Set<String>
|
||||
let atRoom: Bool
|
||||
|
||||
static var empty: Self {
|
||||
IntentionalMentions(userIDs: [], atRoom: false)
|
||||
}
|
||||
}
|
||||
|
||||
extension IntentionalMentions {
|
||||
func toRustMentions() -> Mentions {
|
||||
Mentions(userIds: Array(userIDs), room: atRoom)
|
||||
}
|
||||
}
|
||||
|
||||
extension MentionsState {
|
||||
func toIntentionalMentions() -> IntentionalMentions {
|
||||
IntentionalMentions(userIDs: Set(userIds), atRoom: hasAtRoomMention)
|
||||
}
|
||||
}
|
||||
+8
-2
@@ -66,11 +66,17 @@ class MockRoomTimelineController: RoomTimelineControllerProtocol {
|
||||
|
||||
func processItemTap(_ itemID: TimelineItemIdentifier) async -> RoomTimelineControllerAction { .none }
|
||||
|
||||
func sendMessage(_ message: String, html: String?, inReplyTo itemID: TimelineItemIdentifier?) async { }
|
||||
func sendMessage(_ message: String,
|
||||
html: String?,
|
||||
inReplyTo itemID: TimelineItemIdentifier?,
|
||||
intentionalMentions: IntentionalMentions) async { }
|
||||
|
||||
func toggleReaction(_ reaction: String, to itemID: TimelineItemIdentifier) async { }
|
||||
|
||||
func editMessage(_ newMessage: String, html: String?, original itemID: TimelineItemIdentifier) async { }
|
||||
func editMessage(_ newMessage: String,
|
||||
html: String?,
|
||||
original itemID: TimelineItemIdentifier,
|
||||
intentionalMentions: IntentionalMentions) async { }
|
||||
|
||||
func redact(_ itemID: TimelineItemIdentifier) async { }
|
||||
|
||||
|
||||
@@ -130,7 +130,10 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func sendMessage(_ message: String, html: String?, inReplyTo itemID: TimelineItemIdentifier?) async {
|
||||
func sendMessage(_ message: String,
|
||||
html: String?,
|
||||
inReplyTo itemID: TimelineItemIdentifier?,
|
||||
intentionalMentions: IntentionalMentions) async {
|
||||
var inReplyTo: String?
|
||||
if itemID == nil {
|
||||
MXLog.info("Send message in \(roomID)")
|
||||
@@ -142,7 +145,10 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
return
|
||||
}
|
||||
|
||||
switch await roomProxy.sendMessage(message, html: html, inReplyTo: inReplyTo) {
|
||||
switch await roomProxy.sendMessage(message,
|
||||
html: html,
|
||||
inReplyTo: inReplyTo,
|
||||
intentionalMentions: intentionalMentions) {
|
||||
case .success:
|
||||
MXLog.info("Finished sending message")
|
||||
case .failure(let error):
|
||||
@@ -165,16 +171,22 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func editMessage(_ newMessage: String, html: String?, original itemID: TimelineItemIdentifier) async {
|
||||
func editMessage(_ newMessage: String,
|
||||
html: String?,
|
||||
original itemID: TimelineItemIdentifier,
|
||||
intentionalMentions: IntentionalMentions) async {
|
||||
MXLog.info("Edit message in \(roomID)")
|
||||
if let timelineItem = timelineItems.firstUsingStableID(itemID),
|
||||
let item = timelineItem as? EventBasedTimelineItemProtocol,
|
||||
item.hasFailedToSend {
|
||||
MXLog.info("Editing a failed echo, will cancel and resend it as a new message")
|
||||
await cancelSend(itemID)
|
||||
await sendMessage(newMessage, html: html)
|
||||
await sendMessage(newMessage, html: html, intentionalMentions: intentionalMentions)
|
||||
} else if let eventID = itemID.eventID {
|
||||
switch await roomProxy.editMessage(newMessage, html: html, original: eventID) {
|
||||
switch await roomProxy.editMessage(newMessage,
|
||||
html: html,
|
||||
original: eventID,
|
||||
intentionalMentions: intentionalMentions) {
|
||||
case .success:
|
||||
MXLog.info("Finished editing message")
|
||||
case .failure(let error):
|
||||
|
||||
+15
-4
@@ -51,9 +51,15 @@ protocol RoomTimelineControllerProtocol {
|
||||
|
||||
func sendReadReceipt(for itemID: TimelineItemIdentifier) async -> Result<Void, RoomTimelineControllerError>
|
||||
|
||||
func sendMessage(_ message: String, html: String?, inReplyTo itemID: TimelineItemIdentifier?) async
|
||||
func sendMessage(_ message: String,
|
||||
html: String?,
|
||||
inReplyTo itemID: TimelineItemIdentifier?,
|
||||
intentionalMentions: IntentionalMentions) async
|
||||
|
||||
func editMessage(_ newMessage: String, html: String?, original itemID: TimelineItemIdentifier) async
|
||||
func editMessage(_ newMessage: String,
|
||||
html: String?,
|
||||
original itemID: TimelineItemIdentifier,
|
||||
intentionalMentions: IntentionalMentions) async
|
||||
|
||||
func toggleReaction(_ reaction: String, to itemID: TimelineItemIdentifier) async
|
||||
|
||||
@@ -75,7 +81,12 @@ protocol RoomTimelineControllerProtocol {
|
||||
}
|
||||
|
||||
extension RoomTimelineControllerProtocol {
|
||||
func sendMessage(_ message: String, html: String?) async {
|
||||
await sendMessage(message, html: html, inReplyTo: nil)
|
||||
func sendMessage(_ message: String,
|
||||
html: String?,
|
||||
intentionalMentions: IntentionalMentions) async {
|
||||
await sendMessage(message,
|
||||
html: html,
|
||||
inReplyTo: nil,
|
||||
intentionalMentions: intentionalMentions)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user