Message editing (#298)

* Add translation for editing mode

* Add `is_editable` flag to timeline item

* Add edit api implementation

* Add edit context menu action

* Add changelog

* Update Rust package

* Add isEditable into video timeline item

* Fix cyclomatic complexity

* Fix video item thumbnail loading

* Fix not updating timeline layout
This commit is contained in:
ismailgulek
2022-11-10 14:41:38 +03:00
committed by GitHub
parent 9f12b34a98
commit 3401d7a7e2
36 changed files with 189 additions and 31 deletions
@@ -65,6 +65,10 @@ struct MockRoomProxy: RoomProxyProtocol {
func sendMessage(_ message: String, inReplyToEventId: String? = nil) async -> Result<Void, RoomProxyError> {
.failure(.failedSendingMessage)
}
func editMessage(_ newMessage: String, originalEventId: String) async -> Result<Void, RoomProxyError> {
.failure(.failedSendingMessage)
}
func redact(_ eventID: String) async -> Result<Void, RoomProxyError> {
.failure(.failedRedactingEvent)
@@ -188,6 +188,24 @@ class RoomProxy: RoomProxyProtocol {
}
}
}
func editMessage(_ newMessage: String, originalEventId: String) async -> Result<Void, RoomProxyError> {
sendMessageBgTask = backgroundTaskService.startBackgroundTask(withName: "SendMessage", isReusable: true)
defer {
sendMessageBgTask?.stop()
}
let transactionId = genTransactionId()
return await Task.dispatch(on: .global()) {
do {
try self.room.edit(newMsg: newMessage, originalEventId: originalEventId, txnId: transactionId)
return .success(())
} catch {
return .failure(.failedSendingMessage)
}
}
}
func redact(_ eventID: String) async -> Result<Void, RoomProxyError> {
let transactionID = genTransactionId()
@@ -59,6 +59,8 @@ protocol RoomProxyProtocol {
func paginateBackwards(count: UInt) async -> Result<Void, RoomProxyError>
func sendMessage(_ message: String, inReplyToEventId: String?) async -> Result<Void, RoomProxyError>
func editMessage(_ newMessage: String, originalEventId: String) async -> Result<Void, RoomProxyError>
func redact(_ eventID: String) async -> Result<Void, RoomProxyError>
}