mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Add redaction menu (disabled).
This commit is contained in:
@@ -57,4 +57,8 @@ struct MockRoomProxy: RoomProxyProtocol {
|
||||
func sendMessage(_ message: String) async -> Result<Void, RoomProxyError> {
|
||||
.failure(.failedSendingMessage)
|
||||
}
|
||||
|
||||
func redactItem(_ itemId: String) async -> Result<Void, RoomProxyError> {
|
||||
.failure(.failedRedactingEvent)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,6 +194,22 @@ class RoomProxy: RoomProxyProtocol {
|
||||
.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
|
||||
|
||||
fileprivate func appendMessage(_ message: AnyMessage) {
|
||||
|
||||
@@ -24,6 +24,7 @@ enum RoomProxyError: Error {
|
||||
case failedRetrievingMemberAvatarURL
|
||||
case failedRetrievingMemberDisplayName
|
||||
case failedSendingMessage
|
||||
case failedRedactingEvent
|
||||
}
|
||||
|
||||
enum RoomProxyCallback {
|
||||
@@ -56,5 +57,7 @@ protocol RoomProxyProtocol {
|
||||
|
||||
func sendMessage(_ message: String) async -> Result<Void, RoomProxyError>
|
||||
|
||||
func redactItem(_ itemId: String) async -> Result<Void, RoomProxyError>
|
||||
|
||||
var callbacks: PassthroughSubject<RoomProxyCallback, Never> { get }
|
||||
}
|
||||
|
||||
@@ -57,4 +57,6 @@ class MockRoomTimelineController: RoomTimelineControllerProtocol {
|
||||
func processItemDisappearance(_ itemId: 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
|
||||
|
||||
@objc private func contentSizeCategoryDidChange() {
|
||||
|
||||
@@ -40,4 +40,6 @@ protocol RoomTimelineControllerProtocol {
|
||||
func paginateBackwards(_ count: UInt) async -> Result<Void, RoomTimelineControllerError>
|
||||
|
||||
func sendMessage(_ message: String) async
|
||||
|
||||
func redactItem(_ itemId: String) async
|
||||
}
|
||||
|
||||
@@ -59,4 +59,13 @@ class RoomTimelineProvider: RoomTimelineProviderProtocol {
|
||||
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 {
|
||||
case failedSendingMessage
|
||||
case failedRedactingItem
|
||||
case generic
|
||||
}
|
||||
|
||||
@@ -35,4 +36,6 @@ protocol RoomTimelineProviderProtocol {
|
||||
func paginateBackwards(_ count: UInt) async -> Result<Void, RoomTimelineProviderError>
|
||||
|
||||
func sendMessage(_ message: String) async -> Result<Void, RoomTimelineProviderError>
|
||||
|
||||
func redactItem(_ itemID: String) async -> Result<Void, RoomTimelineProviderError>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user