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

View File

@ -158,6 +158,7 @@ const (
SelectReply SelectReason = "reply to" SelectReply SelectReason = "reply to"
SelectReact = "react to" SelectReact = "react to"
SelectRedact = "redact" SelectRedact = "redact"
SelectEdit = "edit"
SelectDownload = "download" SelectDownload = "download"
SelectOpen = "open" SelectOpen = "open"
SelectCopy = "copy" SelectCopy = "copy"
@ -167,6 +168,10 @@ func cmdReply(cmd *Command) {
cmd.Room.StartSelecting(SelectReply, strings.Join(cmd.Args, " ")) cmd.Room.StartSelecting(SelectReply, strings.Join(cmd.Args, " "))
} }
func cmdEdit(cmd *Command) {
cmd.Room.StartSelecting(SelectEdit, "")
}
func cmdRedact(cmd *Command) { func cmdRedact(cmd *Command) {
cmd.Room.StartSelecting(SelectRedact, strings.Join(cmd.Args, " ")) 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. /reply [text] - Reply to the selected message.
/react <reaction> - React to the selected message. /react <reaction> - React to the selected message.
/redact [reason] - Redact the selected message. /redact [reason] - Redact the selected message.
/edit - Edit the selected message.
# Encryption # Encryption
/fingerprint - View the fingerprint of your device. /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 { if len(view.selectContent) > 0 {
go view.SendMessage(event.MsgText, view.selectContent) go view.SendMessage(event.MsgText, view.selectContent)
} }
case SelectEdit:
view.SetEditing(message.Event)
case SelectReact: case SelectReact:
go view.SendReaction(message.EventID, view.selectContent) go view.SendReaction(message.EventID, view.selectContent)
case SelectRedact: case SelectRedact: