mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Add support for adding/editing/removing media captions. (#3547)
* Add support for editing media captions. * Add composer snapshots. * PR comment.
This commit is contained in:
@@ -91,6 +91,13 @@ class MockRoomTimelineController: RoomTimelineControllerProtocol {
|
||||
html: String?,
|
||||
intentionalMentions: IntentionalMentions) async { }
|
||||
|
||||
func editCaption(_ eventOrTransactionID: EventOrTransactionId,
|
||||
message: String,
|
||||
html: String?,
|
||||
intentionalMentions: IntentionalMentions) async { }
|
||||
|
||||
func removeCaption(_ eventOrTransactionID: EventOrTransactionId) async { }
|
||||
|
||||
func redact(_ eventOrTransactionID: EventOrTransactionId) async { }
|
||||
|
||||
func pin(eventID: String) async { }
|
||||
|
||||
@@ -238,7 +238,7 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
html: html,
|
||||
intentionalMentions: intentionalMentions.toRustMentions())
|
||||
|
||||
switch await activeTimeline.edit(eventOrTransactionID, newContent: messageContent) {
|
||||
switch await activeTimeline.edit(eventOrTransactionID, newContent: .roomMessage(content: messageContent)) {
|
||||
case .success:
|
||||
MXLog.info("Finished editing message by event")
|
||||
case let .failure(error):
|
||||
@@ -246,6 +246,34 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func editCaption(_ eventOrTransactionID: EventOrTransactionId,
|
||||
message: String,
|
||||
html: String?,
|
||||
intentionalMentions: IntentionalMentions) async {
|
||||
// We're waiting on an API for including mentions: https://github.com/matrix-org/matrix-rust-sdk/issues/4302
|
||||
MXLog.info("Editing timeline item caption: \(eventOrTransactionID) in \(roomID)")
|
||||
|
||||
// When formattedCaption is nil, caption will be parsed as markdown and generate the HTML for us.
|
||||
let newContent = createCaptionEdit(caption: message, formattedCaption: html.map { .init(format: .html, body: $0) })
|
||||
switch await activeTimeline.edit(eventOrTransactionID, newContent: newContent) {
|
||||
case .success:
|
||||
MXLog.info("Finished editing caption")
|
||||
case let .failure(error):
|
||||
MXLog.error("Failed editing caption with error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
func removeCaption(_ eventOrTransactionID: EventOrTransactionId) async {
|
||||
// Set a `nil` caption to remove it from the event.
|
||||
let newContent = createCaptionEdit(caption: nil, formattedCaption: nil)
|
||||
switch await activeTimeline.edit(eventOrTransactionID, newContent: newContent) {
|
||||
case .success:
|
||||
MXLog.info("Finished removing caption.")
|
||||
case let .failure(error):
|
||||
MXLog.error("Failed removing caption with error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
func redact(_ eventOrTransactionID: EventOrTransactionId) async {
|
||||
MXLog.info("Send redaction in \(roomID)")
|
||||
|
||||
|
||||
+7
@@ -56,6 +56,13 @@ protocol RoomTimelineControllerProtocol {
|
||||
html: String?,
|
||||
intentionalMentions: IntentionalMentions) async
|
||||
|
||||
func editCaption(_ eventOrTransactionID: EventOrTransactionId,
|
||||
message: String,
|
||||
html: String?,
|
||||
intentionalMentions: IntentionalMentions) async
|
||||
|
||||
func removeCaption(_ eventOrTransactionID: EventOrTransactionId) async
|
||||
|
||||
func toggleReaction(_ reaction: String, to eventOrTransactionID: EventOrTransactionId) async
|
||||
|
||||
func redact(_ eventOrTransactionID: EventOrTransactionId) async
|
||||
|
||||
Reference in New Issue
Block a user