Editing a previously sent message is painful compared to other instant messaging solutions.
While typing in a conversation and willing to edit your last message, you need to:
Cmd + Enter
Yeah, it'd be good to make this easier, since editing the last message is the common case (even if we do still want to support the existing mechanism for editing older messages). I think there are 2 things we should do:
e to start edit
Does that sound reasonable to do you @bmalynovytch?
Thank you for your message 👍
The arrow keys are the main way most folks navigate messages using the keyboard, so I don't think we can repurpose the up key.
Left arrow key might be a good choice for this, what do you think @bmalynovytch?
Hmm ... Why not, it's straightforward. Is it hard to implement ?
I haven't investigated specifically, but I suspect it would not be hard; likely a small amount of code in static/js/hotkeys.js that checks that the hotkey was pressed in the right context and then calls the appropriate function to start an edit on the latest message the user sent.
@timabbott I would like to work on this issue. I have gone through all the linked .js files. I need a little more assistance regarding the same. Could you please guide me?
Sure. I think what you need to do is:
(1) Add code in hotkey.js to handle the left-arrow hotkey; you can start with making it just do alert("Left"); to test your logic for triggering it in the right circumstances.
(2) Once you're happy with that logic, make it instead call message_edit.start() on the last message that the user sent in the currently visible view. The tricky part is computing the last message sent by the user in the current view; we'll probably need to add a new function in message_list.js that loops through the messages and checks whether the sender matches the current user.
@timabbott I could get left arrow to work. And to call message_edit.start() , I need the row id of the message that is in focus. I am having a tough time figuring how to get the row id of a focused message from an event triggered by keyboard. Most of the code has the lines when event is triggered by clicks. And for the tricky part, I will immediately read and understand message_list.js .
Cool. Just to clarify: I think we want to trigger editing on the last message the user sent, not the currently selected message; getting the current selected message is easy (msg_list.selected_id() works), but unfortunately that does't do what we want.
@deekshaarul are you still working on this?
@timabbott I was working on this, though I won't be able to devote time for the next two weeks due to my semester exams.
If anyone wishes to take this, please feel free.
If no one takes this by first week of December, I am open to working on this. :)
@deekshaarul I have started working on this and it's almost finished I'd post a PR within a day or two.
@timabbott I had one question. Do we have to enable the user to edit the very last message he sent OR the last message the user sent in each stream and topic?
Added keyboard shortcut to edit the last message
Added keyboard shortcut to edit the last message.
Tweaked significantly by tabbott to update Casper tests, document the
new feature, and fix hotkeys.