Add /edit command. Fixes #200

This commit is contained in:
Tulir Asokan 2020-08-31 01:23:14 +03:00
parent 2aeaff5b97
commit d9407ee8ee
3 changed files with 10 additions and 0 deletions

View File

@ -101,6 +101,7 @@ func NewCommandProcessor(parent *MainView) *CommandProcessor {
"remove": {"redact"},
"rm": {"redact"},
"del": {"redact"},
"e": {"edit"},
"dl": {"download"},
"o": {"open"},
},
@ -135,6 +136,7 @@ func NewCommandProcessor(parent *MainView) *CommandProcessor {
"reply": cmdReply,
"redact": cmdRedact,
"react": cmdReact,
"edit": cmdEdit,
"download": cmdDownload,
"open": cmdOpen,
"copy": cmdCopy,

View File

@ -158,6 +158,7 @@ const (
SelectReply SelectReason = "reply to"
SelectReact = "react to"
SelectRedact = "redact"
SelectEdit = "edit"
SelectDownload = "download"
SelectOpen = "open"
SelectCopy = "copy"
@ -167,6 +168,10 @@ func cmdReply(cmd *Command) {
cmd.Room.StartSelecting(SelectReply, strings.Join(cmd.Args, " "))
}
func cmdEdit(cmd *Command) {
cmd.Room.StartSelecting(SelectEdit, "")
}
func cmdRedact(cmd *Command) {
cmd.Room.StartSelecting(SelectRedact, strings.Join(cmd.Args, " "))
}
@ -450,6 +455,7 @@ Things: rooms, users, baremessages, images, typingnotif, unverified
/reply [text] - Reply to the selected message.
/react <reaction> - React to the selected message.
/redact [reason] - Redact the selected message.
/edit - Edit the selected message.
# Encryption
/fingerprint - View the fingerprint of your device.

View File

@ -197,6 +197,8 @@ func (view *RoomView) OnSelect(message *messages.UIMessage) {
if len(view.selectContent) > 0 {
go view.SendMessage(event.MsgText, view.selectContent)
}
case SelectEdit:
view.SetEditing(message.Event)
case SelectReact:
go view.SendReaction(message.EventID, view.selectContent)
case SelectRedact: