Revert "Add redaction menu (disabled)."

This reverts commit bd4a698f8b.
This commit is contained in:
Doug
2022-09-14 09:44:15 +01:00
parent bd4a698f8b
commit 2986f85bcb
12 changed files with 10 additions and 78 deletions
@@ -23,7 +23,6 @@ enum TimelineItemContextMenuAction: Hashable {
case copy case copy
case quote case quote
case copyPermalink case copyPermalink
case redact
} }
enum RoomScreenViewAction { enum RoomScreenViewAction {
@@ -116,16 +116,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
return [] return []
} }
let actions: [TimelineItemContextMenuAction] = [ return [.copy, .quote, .copyPermalink]
.copy, .quote, .copyPermalink
]
#warning("Outgoing actions to be handled with the new Timeline API.")
// if timelineItem.isOutgoing {
// actions.append(.redact)
// }
return actions
} }
private func processContentMenuAction(_ action: TimelineItemContextMenuAction, itemId: String) { private func processContentMenuAction(_ action: TimelineItemContextMenuAction, itemId: String) {
@@ -146,8 +137,6 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
} catch { } catch {
displayError(.alert(ElementL10n.roomTimelinePermalinkCreationFailure)) displayError(.alert(ElementL10n.roomTimelinePermalinkCreationFailure))
} }
case .redact:
redactItem(itemId)
} }
} }
@@ -159,10 +148,4 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
message: message) message: message)
} }
} }
private func redactItem(_ itemID: String) {
Task {
await timelineController.redactItem(itemID)
}
}
} }
@@ -25,20 +25,16 @@ public struct TimelineItemContextMenu: View {
ForEach(contextMenuActions, id: \.self) { item in ForEach(contextMenuActions, id: \.self) { item in
switch item { switch item {
case .copy: case .copy:
Button { callback(item) } label: { Button(ElementL10n.actionCopy) {
Label(ElementL10n.actionCopy, systemImage: "doc.on.doc") callback(item)
} }
case .quote: case .quote:
Button { callback(item) } label: { Button(ElementL10n.actionQuote) {
Label(ElementL10n.actionQuote, systemImage: "quote.bubble") callback(item)
} }
case .copyPermalink: case .copyPermalink:
Button { callback(item) } label: { Button(ElementL10n.permalink) {
Label(ElementL10n.permalink, systemImage: "link") callback(item)
}
case .redact:
Button(role: .destructive) { callback(item) } label: {
Label(ElementL10n.messageActionItemRedact, systemImage: "trash")
} }
} }
} }
@@ -57,8 +57,4 @@ struct MockRoomProxy: RoomProxyProtocol {
func sendMessage(_ message: String) async -> Result<Void, RoomProxyError> { func sendMessage(_ message: String) async -> Result<Void, RoomProxyError> {
.failure(.failedSendingMessage) .failure(.failedSendingMessage)
} }
func redactItem(_ itemId: String) async -> Result<Void, RoomProxyError> {
.failure(.failedRedactingEvent)
}
} }
@@ -194,22 +194,6 @@ class RoomProxy: RoomProxyProtocol {
.value .value
} }
func redactItem(_ itemId: String) async -> Result<Void, RoomProxyError> {
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 // MARK: - Private
fileprivate func appendMessage(_ message: AnyMessage) { fileprivate func appendMessage(_ message: AnyMessage) {
@@ -24,7 +24,6 @@ enum RoomProxyError: Error {
case failedRetrievingMemberAvatarURL case failedRetrievingMemberAvatarURL
case failedRetrievingMemberDisplayName case failedRetrievingMemberDisplayName
case failedSendingMessage case failedSendingMessage
case failedRedactingEvent
} }
enum RoomProxyCallback { enum RoomProxyCallback {
@@ -57,7 +56,5 @@ protocol RoomProxyProtocol {
func sendMessage(_ message: String) async -> Result<Void, RoomProxyError> func sendMessage(_ message: String) async -> Result<Void, RoomProxyError>
func redactItem(_ itemId: String) async -> Result<Void, RoomProxyError>
var callbacks: PassthroughSubject<RoomProxyCallback, Never> { get } var callbacks: PassthroughSubject<RoomProxyCallback, Never> { get }
} }
@@ -57,6 +57,4 @@ class MockRoomTimelineController: RoomTimelineControllerProtocol {
func processItemDisappearance(_ itemId: String) async { } func processItemDisappearance(_ itemId: String) async { }
func sendMessage(_ message: String) async { } func sendMessage(_ message: String) async { }
func redactItem(_ itemId: String) async { }
} }
@@ -104,13 +104,6 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
} }
} }
func redactItem(_ itemId: String) async {
switch await timelineProvider.redactItem(itemId) {
default:
break
}
}
// MARK: - Private // MARK: - Private
@objc private func contentSizeCategoryDidChange() { @objc private func contentSizeCategoryDidChange() {
@@ -40,6 +40,4 @@ protocol RoomTimelineControllerProtocol {
func paginateBackwards(_ count: UInt) async -> Result<Void, RoomTimelineControllerError> func paginateBackwards(_ count: UInt) async -> Result<Void, RoomTimelineControllerError>
func sendMessage(_ message: String) async func sendMessage(_ message: String) async
func redactItem(_ itemId: String) async
} }
@@ -59,13 +59,4 @@ class RoomTimelineProvider: RoomTimelineProviderProtocol {
return .failure(.failedSendingMessage) return .failure(.failedSendingMessage)
} }
} }
func redactItem(_ itemID: String) async -> Result<Void, RoomTimelineProviderError> {
switch await roomProxy.redactItem(itemID) {
case .success:
return .success(())
case .failure:
return .failure(.failedRedactingItem)
}
}
} }
@@ -23,7 +23,6 @@ enum RoomTimelineProviderCallback {
enum RoomTimelineProviderError: Error { enum RoomTimelineProviderError: Error {
case failedSendingMessage case failedSendingMessage
case failedRedactingItem
case generic case generic
} }
@@ -36,6 +35,4 @@ protocol RoomTimelineProviderProtocol {
func paginateBackwards(_ count: UInt) async -> Result<Void, RoomTimelineProviderError> func paginateBackwards(_ count: UInt) async -> Result<Void, RoomTimelineProviderError>
func sendMessage(_ message: String) async -> Result<Void, RoomTimelineProviderError> func sendMessage(_ message: String) async -> Result<Void, RoomTimelineProviderError>
func redactItem(_ itemID: String) async -> Result<Void, RoomTimelineProviderError>
} }
+3 -3
View File
@@ -32,9 +32,9 @@ include:
packages: packages:
MatrixRustSDK: MatrixRustSDK:
# url: https://github.com/matrix-org/matrix-rust-components-swift.git url: https://github.com/matrix-org/matrix-rust-components-swift
# exactVersion: 1.0.11-alpha exactVersion: 1.0.13-alpha
path: ../matrix-rust-components-swift # path: ../matrix-rust-components-swift
DesignKit: DesignKit:
path: ./ path: ./
AnalyticsEvents: AnalyticsEvents: