Skip to content

Commit

Permalink
suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
Velin92 committed Oct 20, 2023
1 parent fd97b29 commit db93162
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 23 deletions.
16 changes: 8 additions & 8 deletions ElementX/Sources/Mocks/Generated/GeneratedMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1629,12 +1629,12 @@ class RoomProxyMock: RoomProxyProtocol {
var sendMessageHtmlInReplyToIntentionalMentionsCalled: Bool {
return sendMessageHtmlInReplyToIntentionalMentionsCallsCount > 0
}
var sendMessageHtmlInReplyToIntentionalMentionsReceivedArguments: (message: String, html: String?, eventID: String?, intentionalMentions: Mentions)?
var sendMessageHtmlInReplyToIntentionalMentionsReceivedInvocations: [(message: String, html: String?, eventID: String?, intentionalMentions: Mentions)] = []
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?, Mentions) async -> Result<Void, RoomProxyError>)?
var sendMessageHtmlInReplyToIntentionalMentionsClosure: ((String, String?, String?, IntentionalMentions) async -> Result<Void, RoomProxyError>)?

func sendMessage(_ message: String, html: String?, inReplyTo eventID: String?, intentionalMentions: Mentions) async -> Result<Void, RoomProxyError> {
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))
Expand Down Expand Up @@ -1792,12 +1792,12 @@ class RoomProxyMock: RoomProxyProtocol {
var editMessageHtmlOriginalIntentionalMentionsCalled: Bool {
return editMessageHtmlOriginalIntentionalMentionsCallsCount > 0
}
var editMessageHtmlOriginalIntentionalMentionsReceivedArguments: (newMessage: String, html: String?, eventID: String, intentionalMentions: Mentions)?
var editMessageHtmlOriginalIntentionalMentionsReceivedInvocations: [(newMessage: String, html: String?, eventID: String, intentionalMentions: Mentions)] = []
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, Mentions) async -> Result<Void, RoomProxyError>)?
var editMessageHtmlOriginalIntentionalMentionsClosure: ((String, String?, String, IntentionalMentions) async -> Result<Void, RoomProxyError>)?

func editMessage(_ newMessage: String, html: String?, original eventID: String, intentionalMentions: Mentions) async -> Result<Void, RoomProxyError> {
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))
Expand Down
8 changes: 4 additions & 4 deletions ElementX/Sources/Services/Room/RoomProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,15 @@ class RoomProxy: RoomProxyProtocol {
func sendMessage(_ message: String,
html: String?,
inReplyTo eventID: String? = nil,
intentionalMentions: Mentions) async -> Result<Void, RoomProxyError> {
intentionalMentions: IntentionalMentions) async -> Result<Void, RoomProxyError> {
sendMessageBackgroundTask = await backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true)
defer {
sendMessageBackgroundTask?.stop()
}

let messageContent = buildMessageContentFor(message,
html: html,
intentionalMentions: intentionalMentions)
intentionalMentions: intentionalMentions.toRustMentions())

return await Task.dispatch(on: messageSendingDispatchQueue) {
do {
Expand Down Expand Up @@ -443,15 +443,15 @@ class RoomProxy: RoomProxyProtocol {
func editMessage(_ message: String,
html: String?,
original eventID: String,
intentionalMentions: Mentions) async -> Result<Void, RoomProxyError> {
intentionalMentions: IntentionalMentions) async -> Result<Void, RoomProxyError> {
sendMessageBackgroundTask = await backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true)
defer {
sendMessageBackgroundTask?.stop()
}

let messageContent = buildMessageContentFor(message,
html: html,
intentionalMentions: intentionalMentions)
intentionalMentions: intentionalMentions.toRustMentions())

return await Task.dispatch(on: messageSendingDispatchQueue) {
do {
Expand Down
6 changes: 3 additions & 3 deletions ElementX/Sources/Services/Room/RoomProxyProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protocol RoomProxyProtocol {
func sendMessage(_ message: String,
html: String?,
inReplyTo eventID: String?,
intentionalMentions: Mentions) async -> Result<Void, RoomProxyError>
intentionalMentions: IntentionalMentions) async -> Result<Void, RoomProxyError>

func toggleReaction(_ reaction: String, to eventID: String) async -> Result<Void, RoomProxyError>

Expand Down Expand Up @@ -140,7 +140,7 @@ protocol RoomProxyProtocol {
func editMessage(_ newMessage: String,
html: String?,
original eventID: String,
intentionalMentions: Mentions) async -> Result<Void, RoomProxyError>
intentionalMentions: IntentionalMentions) async -> Result<Void, RoomProxyError>

func redact(_ eventID: String) async -> Result<Void, RoomProxyError>

Expand Down Expand Up @@ -205,7 +205,7 @@ extension RoomProxyProtocol {

func sendMessage(_ message: String,
html: String?,
intentionalMentions: Mentions) async -> Result<Void, RoomProxyError> {
intentionalMentions: IntentionalMentions) async -> Result<Void, RoomProxyError> {
await sendMessage(message,
html: html,
inReplyTo: nil,
Expand Down
10 changes: 4 additions & 6 deletions ElementX/Sources/Services/Timeline/IntentionalMentions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import WysiwygComposer
struct IntentionalMentions: Equatable {
let userIDs: Set<String>
let atRoom: Bool

static var empty: Self {
IntentionalMentions(userIDs: [], atRoom: false)
}
}

extension IntentionalMentions {
Expand All @@ -35,9 +39,3 @@ extension MentionsState {
IntentionalMentions(userIDs: Set(userIds), atRoom: hasAtRoomMention)
}
}

extension Mentions {
static var empty: Self {
Mentions(userIds: [], room: false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
switch await roomProxy.sendMessage(message,
html: html,
inReplyTo: inReplyTo,
intentionalMentions: intentionalMentions.toRustMentions()) {
intentionalMentions: intentionalMentions) {
case .success:
MXLog.info("Finished sending message")
case .failure(let error):
Expand Down Expand Up @@ -186,7 +186,7 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
switch await roomProxy.editMessage(newMessage,
html: html,
original: eventID,
intentionalMentions: intentionalMentions.toRustMentions()) {
intentionalMentions: intentionalMentions) {
case .success:
MXLog.info("Finished editing message")
case .failure(let error):
Expand Down

0 comments on commit db93162

Please sign in to comment.