From 2b17c415fbfc688a0788123cbefd403597b8b484 Mon Sep 17 00:00:00 2001 From: Doug Date: Wed, 14 Sep 2022 09:44:15 +0100 Subject: [PATCH] Revert "Add redaction menu (disabled)." This reverts commit 453408dbe9e2130be783d1d1e0037ac6303b1a91. --- .../Screens/RoomScreen/RoomScreenModels.swift | 1 - .../RoomScreen/RoomScreenViewModel.swift | 19 +------------------ .../View/TimelineItemContextMenu.swift | 16 ++++++---------- .../Sources/Services/Room/MockRoomProxy.swift | 4 ---- .../Sources/Services/Room/RoomProxy.swift | 16 ---------------- .../Services/Room/RoomProxyProtocol.swift | 3 --- .../Timeline/MockRoomTimelineController.swift | 2 -- .../Timeline/RoomTimelineController.swift | 7 ------- .../RoomTimelineControllerProtocol.swift | 2 -- .../Timeline/RoomTimelineProvider.swift | 9 --------- .../RoomTimelineProviderProtocol.swift | 3 --- project.yml | 6 +++--- 12 files changed, 10 insertions(+), 78 deletions(-) diff --git a/ElementX/Sources/Screens/RoomScreen/RoomScreenModels.swift b/ElementX/Sources/Screens/RoomScreen/RoomScreenModels.swift index 8e4a44a71..a3f5fec8f 100644 --- a/ElementX/Sources/Screens/RoomScreen/RoomScreenModels.swift +++ b/ElementX/Sources/Screens/RoomScreen/RoomScreenModels.swift @@ -23,7 +23,6 @@ enum TimelineItemContextMenuAction: Hashable { case copy case quote case copyPermalink - case redact } enum RoomScreenViewAction { diff --git a/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift b/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift index 013ca2e72..e2c062040 100644 --- a/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift @@ -116,16 +116,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol return [] } - let actions: [TimelineItemContextMenuAction] = [ - .copy, .quote, .copyPermalink - ] - - #warning("Outgoing actions to be handled with the new Timeline API.") -// if timelineItem.isOutgoing { -// actions.append(.redact) -// } - - return actions + return [.copy, .quote, .copyPermalink] } private func processContentMenuAction(_ action: TimelineItemContextMenuAction, itemId: String) { @@ -146,8 +137,6 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol } catch { displayError(.alert(ElementL10n.roomTimelinePermalinkCreationFailure)) } - case .redact: - redactItem(itemId) } } @@ -159,10 +148,4 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol message: message) } } - - private func redactItem(_ itemID: String) { - Task { - await timelineController.redactItem(itemID) - } - } } diff --git a/ElementX/Sources/Screens/RoomScreen/View/TimelineItemContextMenu.swift b/ElementX/Sources/Screens/RoomScreen/View/TimelineItemContextMenu.swift index b7a32f75c..f4f35287c 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/TimelineItemContextMenu.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/TimelineItemContextMenu.swift @@ -25,20 +25,16 @@ public struct TimelineItemContextMenu: View { ForEach(contextMenuActions, id: \.self) { item in switch item { case .copy: - Button { callback(item) } label: { - Label(ElementL10n.actionCopy, systemImage: "doc.on.doc") + Button(ElementL10n.actionCopy) { + callback(item) } case .quote: - Button { callback(item) } label: { - Label(ElementL10n.actionQuote, systemImage: "quote.bubble") + Button(ElementL10n.actionQuote) { + callback(item) } case .copyPermalink: - Button { callback(item) } label: { - Label(ElementL10n.permalink, systemImage: "link") - } - case .redact: - Button(role: .destructive) { callback(item) } label: { - Label(ElementL10n.messageActionItemRedact, systemImage: "trash") + Button(ElementL10n.permalink) { + callback(item) } } } diff --git a/ElementX/Sources/Services/Room/MockRoomProxy.swift b/ElementX/Sources/Services/Room/MockRoomProxy.swift index 31e2b53f5..2afa83977 100644 --- a/ElementX/Sources/Services/Room/MockRoomProxy.swift +++ b/ElementX/Sources/Services/Room/MockRoomProxy.swift @@ -57,8 +57,4 @@ struct MockRoomProxy: RoomProxyProtocol { func sendMessage(_ message: String) async -> Result { .failure(.failedSendingMessage) } - - func redactItem(_ itemId: String) async -> Result { - .failure(.failedRedactingEvent) - } } diff --git a/ElementX/Sources/Services/Room/RoomProxy.swift b/ElementX/Sources/Services/Room/RoomProxy.swift index 9a6805ba6..e21924cc6 100644 --- a/ElementX/Sources/Services/Room/RoomProxy.swift +++ b/ElementX/Sources/Services/Room/RoomProxy.swift @@ -194,22 +194,6 @@ class RoomProxy: RoomProxyProtocol { .value } - func redactItem(_ itemId: String) async -> Result { - return .failure(.failedRedactingEvent) - #warning("Redactions to be enabled on next SDK release.") -// let transactionID = genTransactionId() -// -// return await Task { -// do { -// try room.redact(eventId: itemId, reason: nil, txnId: transactionID) -// return .success(()) -// } catch { -// return .failure(.failedRedactingEvent) -// } -// } -// .value - } - // MARK: - Private fileprivate func appendMessage(_ message: AnyMessage) { diff --git a/ElementX/Sources/Services/Room/RoomProxyProtocol.swift b/ElementX/Sources/Services/Room/RoomProxyProtocol.swift index 80ff3159b..1e0bf6b58 100644 --- a/ElementX/Sources/Services/Room/RoomProxyProtocol.swift +++ b/ElementX/Sources/Services/Room/RoomProxyProtocol.swift @@ -24,7 +24,6 @@ enum RoomProxyError: Error { case failedRetrievingMemberAvatarURL case failedRetrievingMemberDisplayName case failedSendingMessage - case failedRedactingEvent } enum RoomProxyCallback { @@ -57,7 +56,5 @@ protocol RoomProxyProtocol { func sendMessage(_ message: String) async -> Result - func redactItem(_ itemId: String) async -> Result - var callbacks: PassthroughSubject { get } } diff --git a/ElementX/Sources/Services/Timeline/MockRoomTimelineController.swift b/ElementX/Sources/Services/Timeline/MockRoomTimelineController.swift index e222aa20d..3acd03ca6 100644 --- a/ElementX/Sources/Services/Timeline/MockRoomTimelineController.swift +++ b/ElementX/Sources/Services/Timeline/MockRoomTimelineController.swift @@ -57,6 +57,4 @@ class MockRoomTimelineController: RoomTimelineControllerProtocol { func processItemDisappearance(_ itemId: String) async { } func sendMessage(_ message: String) async { } - - func redactItem(_ itemId: String) async { } } diff --git a/ElementX/Sources/Services/Timeline/RoomTimelineController.swift b/ElementX/Sources/Services/Timeline/RoomTimelineController.swift index 9da685d47..12e2ef8f9 100644 --- a/ElementX/Sources/Services/Timeline/RoomTimelineController.swift +++ b/ElementX/Sources/Services/Timeline/RoomTimelineController.swift @@ -104,13 +104,6 @@ class RoomTimelineController: RoomTimelineControllerProtocol { } } - func redactItem(_ itemId: String) async { - switch await timelineProvider.redactItem(itemId) { - default: - break - } - } - // MARK: - Private @objc private func contentSizeCategoryDidChange() { diff --git a/ElementX/Sources/Services/Timeline/RoomTimelineControllerProtocol.swift b/ElementX/Sources/Services/Timeline/RoomTimelineControllerProtocol.swift index 82d03088c..3b93965ea 100644 --- a/ElementX/Sources/Services/Timeline/RoomTimelineControllerProtocol.swift +++ b/ElementX/Sources/Services/Timeline/RoomTimelineControllerProtocol.swift @@ -40,6 +40,4 @@ protocol RoomTimelineControllerProtocol { func paginateBackwards(_ count: UInt) async -> Result func sendMessage(_ message: String) async - - func redactItem(_ itemId: String) async } diff --git a/ElementX/Sources/Services/Timeline/RoomTimelineProvider.swift b/ElementX/Sources/Services/Timeline/RoomTimelineProvider.swift index 6c62ec626..78609c46f 100644 --- a/ElementX/Sources/Services/Timeline/RoomTimelineProvider.swift +++ b/ElementX/Sources/Services/Timeline/RoomTimelineProvider.swift @@ -59,13 +59,4 @@ class RoomTimelineProvider: RoomTimelineProviderProtocol { return .failure(.failedSendingMessage) } } - - func redactItem(_ itemID: String) async -> Result { - switch await roomProxy.redactItem(itemID) { - case .success: - return .success(()) - case .failure: - return .failure(.failedRedactingItem) - } - } } diff --git a/ElementX/Sources/Services/Timeline/RoomTimelineProviderProtocol.swift b/ElementX/Sources/Services/Timeline/RoomTimelineProviderProtocol.swift index 3ac49263a..15bbba1c4 100644 --- a/ElementX/Sources/Services/Timeline/RoomTimelineProviderProtocol.swift +++ b/ElementX/Sources/Services/Timeline/RoomTimelineProviderProtocol.swift @@ -23,7 +23,6 @@ enum RoomTimelineProviderCallback { enum RoomTimelineProviderError: Error { case failedSendingMessage - case failedRedactingItem case generic } @@ -36,6 +35,4 @@ protocol RoomTimelineProviderProtocol { func paginateBackwards(_ count: UInt) async -> Result func sendMessage(_ message: String) async -> Result - - func redactItem(_ itemID: String) async -> Result } diff --git a/project.yml b/project.yml index dfccf1c8b..7f07c1a20 100644 --- a/project.yml +++ b/project.yml @@ -32,9 +32,9 @@ include: packages: MatrixRustSDK: - # url: https://github.com/matrix-org/matrix-rust-components-swift.git - # exactVersion: 1.0.11-alpha - path: ../matrix-rust-components-swift + url: https://github.com/matrix-org/matrix-rust-components-swift + exactVersion: 1.0.13-alpha + # path: ../matrix-rust-components-swift DesignKit: path: ./ AnalyticsEvents: