From 91795a0d199ae73975fe516ccd17b18f553c1974 Mon Sep 17 00:00:00 2001 From: Doug Date: Wed, 14 Sep 2022 12:19:24 +0100 Subject: [PATCH] Redact and event ID, not an item ID. --- .../Sources/Screens/RoomScreen/RoomScreenViewModel.swift | 6 +++--- ElementX/Sources/Services/Room/MockRoomProxy.swift | 2 +- ElementX/Sources/Services/Room/RoomProxy.swift | 4 ++-- ElementX/Sources/Services/Room/RoomProxyProtocol.swift | 2 +- .../Services/Timeline/MockRoomTimelineController.swift | 2 +- .../Sources/Services/Timeline/RoomTimelineController.swift | 4 ++-- .../Services/Timeline/RoomTimelineControllerProtocol.swift | 2 +- .../Sources/Services/Timeline/RoomTimelineProvider.swift | 4 ++-- .../Services/Timeline/RoomTimelineProviderProtocol.swift | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift b/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift index ebeb2f4d4..e8139cfa0 100644 --- a/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift @@ -150,7 +150,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol displayError(.alert(ElementL10n.roomTimelinePermalinkCreationFailure)) } case .redact: - redactItem(itemId) + redact(itemId) } } @@ -163,9 +163,9 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol } } - private func redactItem(_ itemID: String) { + private func redact(_ eventID: String) { Task { - await timelineController.redactItem(itemID) + await timelineController.redact(eventID) } } } diff --git a/ElementX/Sources/Services/Room/MockRoomProxy.swift b/ElementX/Sources/Services/Room/MockRoomProxy.swift index 31e2b53f5..83e5d0c4e 100644 --- a/ElementX/Sources/Services/Room/MockRoomProxy.swift +++ b/ElementX/Sources/Services/Room/MockRoomProxy.swift @@ -58,7 +58,7 @@ struct MockRoomProxy: RoomProxyProtocol { .failure(.failedSendingMessage) } - func redactItem(_ itemId: String) async -> Result { + func redact(_ eventID: String) async -> Result { .failure(.failedRedactingEvent) } } diff --git a/ElementX/Sources/Services/Room/RoomProxy.swift b/ElementX/Sources/Services/Room/RoomProxy.swift index 57a7bd458..75409c24e 100644 --- a/ElementX/Sources/Services/Room/RoomProxy.swift +++ b/ElementX/Sources/Services/Room/RoomProxy.swift @@ -194,14 +194,14 @@ class RoomProxy: RoomProxyProtocol { .value } - func redactItem(_ itemId: String) async -> Result { + func redactItem(_ eventID: String) async -> Result { #warning("Redactions to be enabled on next SDK release.") return .failure(.failedRedactingEvent) // let transactionID = genTransactionId() // // return await Task { // do { -// try room.redact(eventId: itemId, reason: nil, txnId: transactionID) +// try room.redact(eventId: eventID, reason: nil, txnId: transactionID) // return .success(()) // } catch { // return .failure(.failedRedactingEvent) diff --git a/ElementX/Sources/Services/Room/RoomProxyProtocol.swift b/ElementX/Sources/Services/Room/RoomProxyProtocol.swift index 80ff3159b..d5166baf2 100644 --- a/ElementX/Sources/Services/Room/RoomProxyProtocol.swift +++ b/ElementX/Sources/Services/Room/RoomProxyProtocol.swift @@ -57,7 +57,7 @@ protocol RoomProxyProtocol { func sendMessage(_ message: String) async -> Result - func redactItem(_ itemId: String) async -> Result + func redact(_ eventID: String) async -> Result var callbacks: PassthroughSubject { get } } diff --git a/ElementX/Sources/Services/Timeline/MockRoomTimelineController.swift b/ElementX/Sources/Services/Timeline/MockRoomTimelineController.swift index 5ceaddd1b..83d07fffe 100644 --- a/ElementX/Sources/Services/Timeline/MockRoomTimelineController.swift +++ b/ElementX/Sources/Services/Timeline/MockRoomTimelineController.swift @@ -66,5 +66,5 @@ class MockRoomTimelineController: RoomTimelineControllerProtocol { func sendMessage(_ message: String) async { } - func redactItem(_ itemId: String) async { } + func redact(_ eventID: String) async { } } diff --git a/ElementX/Sources/Services/Timeline/RoomTimelineController.swift b/ElementX/Sources/Services/Timeline/RoomTimelineController.swift index 9da685d47..70bdddad8 100644 --- a/ElementX/Sources/Services/Timeline/RoomTimelineController.swift +++ b/ElementX/Sources/Services/Timeline/RoomTimelineController.swift @@ -104,8 +104,8 @@ class RoomTimelineController: RoomTimelineControllerProtocol { } } - func redactItem(_ itemId: String) async { - switch await timelineProvider.redactItem(itemId) { + func redact(_ eventID: String) async { + switch await timelineProvider.redact(eventID) { default: break } diff --git a/ElementX/Sources/Services/Timeline/RoomTimelineControllerProtocol.swift b/ElementX/Sources/Services/Timeline/RoomTimelineControllerProtocol.swift index 82d03088c..3416bdbc3 100644 --- a/ElementX/Sources/Services/Timeline/RoomTimelineControllerProtocol.swift +++ b/ElementX/Sources/Services/Timeline/RoomTimelineControllerProtocol.swift @@ -41,5 +41,5 @@ protocol RoomTimelineControllerProtocol { func sendMessage(_ message: String) async - func redactItem(_ itemId: String) async + func redact(_ eventID: String) async } diff --git a/ElementX/Sources/Services/Timeline/RoomTimelineProvider.swift b/ElementX/Sources/Services/Timeline/RoomTimelineProvider.swift index 6c62ec626..b0054cbbb 100644 --- a/ElementX/Sources/Services/Timeline/RoomTimelineProvider.swift +++ b/ElementX/Sources/Services/Timeline/RoomTimelineProvider.swift @@ -60,8 +60,8 @@ class RoomTimelineProvider: RoomTimelineProviderProtocol { } } - func redactItem(_ itemID: String) async -> Result { - switch await roomProxy.redactItem(itemID) { + func redact(_ eventID: String) async -> Result { + switch await roomProxy.redact(eventID) { case .success: return .success(()) case .failure: diff --git a/ElementX/Sources/Services/Timeline/RoomTimelineProviderProtocol.swift b/ElementX/Sources/Services/Timeline/RoomTimelineProviderProtocol.swift index 3ac49263a..a84a9e08e 100644 --- a/ElementX/Sources/Services/Timeline/RoomTimelineProviderProtocol.swift +++ b/ElementX/Sources/Services/Timeline/RoomTimelineProviderProtocol.swift @@ -37,5 +37,5 @@ protocol RoomTimelineProviderProtocol { func sendMessage(_ message: String) async -> Result - func redactItem(_ itemID: String) async -> Result + func redact(_ eventID: String) async -> Result }