mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 15:45:11 +00:00
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:
@@ -106,6 +106,8 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
MXLog.warning("React with \(key) failed. Not implemented.")
|
||||
case .cancelReply:
|
||||
state.composerMode = .default
|
||||
case .cancelEdit:
|
||||
state.composerMode = .default
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +141,8 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
switch currentComposerState {
|
||||
case .reply(let itemId, _):
|
||||
await timelineController.sendReply(currentMessage, to: itemId)
|
||||
case .edit(let originalItemId):
|
||||
await timelineController.editMessage(currentMessage, of: originalItemId)
|
||||
default:
|
||||
await timelineController.sendMessage(currentMessage)
|
||||
}
|
||||
@@ -163,15 +167,19 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
|
||||
private func contextMenuActionsForItemId(_ itemId: String) -> TimelineItemContextMenuActions {
|
||||
guard let timelineItem = timelineController.timelineItems.first(where: { $0.id == itemId }),
|
||||
timelineItem is EventBasedTimelineItemProtocol else {
|
||||
let item = timelineItem as? EventBasedTimelineItemProtocol else {
|
||||
return .init(actions: [])
|
||||
}
|
||||
|
||||
var actions: [TimelineItemContextMenuAction] = [
|
||||
.copy, .quote, .copyPermalink, .reply
|
||||
]
|
||||
|
||||
if item.isEditable {
|
||||
actions.append(.edit)
|
||||
}
|
||||
|
||||
if let item = timelineItem as? EventBasedTimelineItemProtocol, item.isOutgoing {
|
||||
if item.isOutgoing {
|
||||
actions.append(.redact)
|
||||
}
|
||||
|
||||
@@ -187,6 +195,10 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
switch action {
|
||||
case .copy:
|
||||
UIPasteboard.general.string = item.text
|
||||
case .edit:
|
||||
state.bindings.composerFocused = true
|
||||
state.bindings.composerText = item.text
|
||||
state.composerMode = .edit(originalItemId: item.id)
|
||||
case .quote:
|
||||
state.bindings.composerFocused = true
|
||||
state.bindings.composerText = "> \(item.text)"
|
||||
@@ -208,10 +220,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
state.bindings.debugInfo = .init(title: "Timeline item", content: debugDescription)
|
||||
}
|
||||
|
||||
switch action {
|
||||
case .reply:
|
||||
break
|
||||
default:
|
||||
if action.switchToDefaultComposer {
|
||||
state.composerMode = .default
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user