mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Rename sendReaction as toggleReaction
This commit is contained in:
committed by
Stefan Ceriu
parent
7d3dcee5a3
commit
88ac3fb8c6
@@ -500,7 +500,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
MXLog.debug("Selected \(emoji) for \(itemId)")
|
||||
self?.navigationStackCoordinator.setSheetCoordinator(nil)
|
||||
Task {
|
||||
await self?.timelineController?.sendReaction(emoji, to: itemId)
|
||||
await self?.timelineController?.toggleReaction(emoji, to: itemId)
|
||||
}
|
||||
case .dismiss:
|
||||
self?.navigationStackCoordinator.setSheetCoordinator(nil)
|
||||
|
||||
@@ -610,25 +610,25 @@ class RoomProxyMock: RoomProxyProtocol {
|
||||
return sendMessageInReplyToReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - sendReaction
|
||||
//MARK: - toggleReaction
|
||||
|
||||
var sendReactionToCallsCount = 0
|
||||
var sendReactionToCalled: Bool {
|
||||
return sendReactionToCallsCount > 0
|
||||
var toggleReactionToCallsCount = 0
|
||||
var toggleReactionToCalled: Bool {
|
||||
return toggleReactionToCallsCount > 0
|
||||
}
|
||||
var sendReactionToReceivedArguments: (reaction: String, eventID: String)?
|
||||
var sendReactionToReceivedInvocations: [(reaction: String, eventID: String)] = []
|
||||
var sendReactionToReturnValue: Result<Void, RoomProxyError>!
|
||||
var sendReactionToClosure: ((String, String) async -> Result<Void, RoomProxyError>)?
|
||||
var toggleReactionToReceivedArguments: (reaction: String, eventID: String)?
|
||||
var toggleReactionToReceivedInvocations: [(reaction: String, eventID: String)] = []
|
||||
var toggleReactionToReturnValue: Result<Void, RoomProxyError>!
|
||||
var toggleReactionToClosure: ((String, String) async -> Result<Void, RoomProxyError>)?
|
||||
|
||||
func sendReaction(_ reaction: String, to eventID: String) async -> Result<Void, RoomProxyError> {
|
||||
sendReactionToCallsCount += 1
|
||||
sendReactionToReceivedArguments = (reaction: reaction, eventID: eventID)
|
||||
sendReactionToReceivedInvocations.append((reaction: reaction, eventID: eventID))
|
||||
if let sendReactionToClosure = sendReactionToClosure {
|
||||
return await sendReactionToClosure(reaction, eventID)
|
||||
func toggleReaction(_ reaction: String, to eventID: String) async -> Result<Void, RoomProxyError> {
|
||||
toggleReactionToCallsCount += 1
|
||||
toggleReactionToReceivedArguments = (reaction: reaction, eventID: eventID)
|
||||
toggleReactionToReceivedInvocations.append((reaction: reaction, eventID: eventID))
|
||||
if let toggleReactionToClosure = toggleReactionToClosure {
|
||||
return await toggleReactionToClosure(reaction, eventID)
|
||||
} else {
|
||||
return sendReactionToReturnValue
|
||||
return toggleReactionToReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - sendImage
|
||||
|
||||
@@ -54,7 +54,7 @@ enum RoomScreenViewAction {
|
||||
case itemTapped(id: String)
|
||||
case linkClicked(url: URL)
|
||||
case sendMessage
|
||||
case sendReaction(key: String, eventID: String)
|
||||
case toggleReaction(key: String, eventID: String)
|
||||
case cancelReply
|
||||
case cancelEdit
|
||||
/// Mark the entire room as read - this is heavy handed as a starting point for now.
|
||||
|
||||
@@ -84,8 +84,8 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
MXLog.warning("Link clicked: \(url)")
|
||||
case .sendMessage:
|
||||
Task { await sendCurrentMessage() }
|
||||
case .sendReaction(let emoji, let itemId):
|
||||
Task { await timelineController.sendReaction(emoji, to: itemId) }
|
||||
case .toggleReaction(let emoji, let itemId):
|
||||
Task { await timelineController.toggleReaction(emoji, to: itemId) }
|
||||
case .cancelReply:
|
||||
setComposerMode(.default)
|
||||
case .cancelEdit:
|
||||
|
||||
@@ -94,7 +94,7 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
|
||||
if !timelineItem.properties.reactions.isEmpty {
|
||||
TimelineReactionsView(reactions: timelineItem.properties.reactions,
|
||||
alignment: alignment) { key in
|
||||
context.send(viewAction: .sendReaction(key: key, eventID: timelineItem.id))
|
||||
context.send(viewAction: .toggleReaction(key: key, eventID: timelineItem.id))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ struct TimelineItemPlainStylerView<Content: View>: View {
|
||||
if !timelineItem.properties.reactions.isEmpty {
|
||||
TimelineReactionsView(reactions: timelineItem.properties.reactions,
|
||||
alignment: .leading) { key in
|
||||
context.send(viewAction: .sendReaction(key: key, eventID: timelineItem.id))
|
||||
context.send(viewAction: .toggleReaction(key: key, eventID: timelineItem.id))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public struct TimelineItemMenu: View {
|
||||
private func reactionButton(for emoji: String) -> some View {
|
||||
Button {
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
context.send(viewAction: .sendReaction(key: emoji, eventID: item.id))
|
||||
context.send(viewAction: .toggleReaction(key: emoji, eventID: item.id))
|
||||
} label: {
|
||||
Text(emoji)
|
||||
.padding(8.0)
|
||||
|
||||
@@ -260,7 +260,7 @@ class RoomProxy: RoomProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func sendReaction(_ reaction: String, to eventID: String) async -> Result<Void, RoomProxyError> {
|
||||
func toggleReaction(_ reaction: String, to eventID: String) async -> Result<Void, RoomProxyError> {
|
||||
sendMessageBackgroundTask = backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true)
|
||||
defer {
|
||||
sendMessageBackgroundTask?.stop()
|
||||
@@ -268,7 +268,7 @@ class RoomProxy: RoomProxyProtocol {
|
||||
|
||||
return await Task.dispatch(on: userInitiatedDispatchQueue) {
|
||||
do {
|
||||
try self.room.sendReaction(eventId: eventID, key: reaction)
|
||||
try self.room.toggleReaction(eventId: eventID, key: reaction)
|
||||
return .success(())
|
||||
} catch {
|
||||
return .failure(.failedSendingReaction)
|
||||
|
||||
@@ -92,7 +92,7 @@ protocol RoomProxyProtocol {
|
||||
|
||||
func sendMessage(_ message: String, inReplyTo eventID: String?) async -> Result<Void, RoomProxyError>
|
||||
|
||||
func sendReaction(_ reaction: String, to eventID: String) async -> Result<Void, RoomProxyError>
|
||||
func toggleReaction(_ reaction: String, to eventID: String) async -> Result<Void, RoomProxyError>
|
||||
|
||||
func sendImage(url: URL, thumbnailURL: URL, imageInfo: ImageInfo, progressSubject: CurrentValueSubject<Double, Never>?) async -> Result<Void, RoomProxyError>
|
||||
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ class MockRoomTimelineController: RoomTimelineControllerProtocol {
|
||||
|
||||
func sendMessage(_ message: String, inReplyTo itemID: String?) async { }
|
||||
|
||||
func sendReaction(_ reaction: String, to itemID: String) async { }
|
||||
func toggleReaction(_ reaction: String, to itemID: String) async { }
|
||||
|
||||
func editMessage(_ newMessage: String, original itemID: String) async { }
|
||||
|
||||
|
||||
@@ -156,13 +156,13 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func sendReaction(_ reaction: String, to itemID: String) async {
|
||||
MXLog.info("Send reaction in \(roomID)")
|
||||
switch await roomProxy.sendReaction(reaction, to: itemID) {
|
||||
func toggleReaction(_ reaction: String, to itemID: String) async {
|
||||
MXLog.info("Toggle reaction in \(roomID)")
|
||||
switch await roomProxy.toggleReaction(reaction, to: itemID) {
|
||||
case .success:
|
||||
MXLog.info("Finished sending reaction")
|
||||
MXLog.info("Finished toggling reaction")
|
||||
case .failure(let error):
|
||||
MXLog.error("Failed sending reaction with error: \(error)")
|
||||
MXLog.error("Failed toggling reaction with error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ protocol RoomTimelineControllerProtocol {
|
||||
|
||||
func editMessage(_ newMessage: String, original itemID: String) async
|
||||
|
||||
func sendReaction(_ reaction: String, to itemID: String) async
|
||||
func toggleReaction(_ reaction: String, to itemID: String) async
|
||||
|
||||
func redact(_ itemID: String) async
|
||||
|
||||
|
||||
Reference in New Issue
Block a user