mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 15:45:11 +00:00
Add redaction menu (disabled).
This commit is contained in:
@@ -23,6 +23,7 @@ enum TimelineItemContextMenuAction: Hashable {
|
|||||||
case copy
|
case copy
|
||||||
case quote
|
case quote
|
||||||
case copyPermalink
|
case copyPermalink
|
||||||
|
case redact
|
||||||
}
|
}
|
||||||
|
|
||||||
enum RoomScreenViewAction {
|
enum RoomScreenViewAction {
|
||||||
|
|||||||
@@ -116,7 +116,16 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
return [.copy, .quote, .copyPermalink]
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
private func processContentMenuAction(_ action: TimelineItemContextMenuAction, itemId: String) {
|
private func processContentMenuAction(_ action: TimelineItemContextMenuAction, itemId: String) {
|
||||||
@@ -137,6 +146,8 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
|||||||
} catch {
|
} catch {
|
||||||
displayError(.alert(ElementL10n.roomTimelinePermalinkCreationFailure))
|
displayError(.alert(ElementL10n.roomTimelinePermalinkCreationFailure))
|
||||||
}
|
}
|
||||||
|
case .redact:
|
||||||
|
redactItem(itemId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,4 +159,10 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
|||||||
message: message)
|
message: message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func redactItem(_ itemID: String) {
|
||||||
|
Task {
|
||||||
|
await timelineController.redactItem(itemID)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,16 +25,20 @@ 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(ElementL10n.actionCopy) {
|
Button { callback(item) } label: {
|
||||||
callback(item)
|
Label(ElementL10n.actionCopy, systemImage: "doc.on.doc")
|
||||||
}
|
}
|
||||||
case .quote:
|
case .quote:
|
||||||
Button(ElementL10n.actionQuote) {
|
Button { callback(item) } label: {
|
||||||
callback(item)
|
Label(ElementL10n.actionQuote, systemImage: "quote.bubble")
|
||||||
}
|
}
|
||||||
case .copyPermalink:
|
case .copyPermalink:
|
||||||
Button(ElementL10n.permalink) {
|
Button { callback(item) } label: {
|
||||||
callback(item)
|
Label(ElementL10n.permalink, systemImage: "link")
|
||||||
|
}
|
||||||
|
case .redact:
|
||||||
|
Button(role: .destructive) { callback(item) } label: {
|
||||||
|
Label(ElementL10n.messageActionItemRedact, systemImage: "trash")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,8 @@ 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,6 +194,22 @@ 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,6 +24,7 @@ enum RoomProxyError: Error {
|
|||||||
case failedRetrievingMemberAvatarURL
|
case failedRetrievingMemberAvatarURL
|
||||||
case failedRetrievingMemberDisplayName
|
case failedRetrievingMemberDisplayName
|
||||||
case failedSendingMessage
|
case failedSendingMessage
|
||||||
|
case failedRedactingEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
enum RoomProxyCallback {
|
enum RoomProxyCallback {
|
||||||
@@ -56,5 +57,7 @@ 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,4 +57,6 @@ 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,6 +104,13 @@ 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,4 +40,6 @@ 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,4 +59,13 @@ 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,6 +23,7 @@ enum RoomTimelineProviderCallback {
|
|||||||
|
|
||||||
enum RoomTimelineProviderError: Error {
|
enum RoomTimelineProviderError: Error {
|
||||||
case failedSendingMessage
|
case failedSendingMessage
|
||||||
|
case failedRedactingItem
|
||||||
case generic
|
case generic
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,4 +36,6 @@ 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
@@ -32,9 +32,9 @@ include:
|
|||||||
|
|
||||||
packages:
|
packages:
|
||||||
MatrixRustSDK:
|
MatrixRustSDK:
|
||||||
url: https://github.com/matrix-org/matrix-rust-components-swift
|
# url: https://github.com/matrix-org/matrix-rust-components-swift.git
|
||||||
exactVersion: 1.0.13-alpha
|
# exactVersion: 1.0.11-alpha
|
||||||
# path: ../matrix-rust-components-swift
|
path: ../matrix-rust-components-swift
|
||||||
DesignKit:
|
DesignKit:
|
||||||
path: ./
|
path: ./
|
||||||
AnalyticsEvents:
|
AnalyticsEvents:
|
||||||
|
|||||||
Reference in New Issue
Block a user