add shortcut that opens a comment thread for most recent message in a channel (#6549)

This commit is contained in:
Saturnino Abril
2017-06-03 00:11:03 +08:00
committed by Christopher Speller
parent 6a54f3c489
commit f1b317a51f
3 changed files with 16 additions and 1 deletions

View File

@@ -37,7 +37,7 @@ func (me *ShortcutsProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
}
func (me *ShortcutsProvider) DoCommand(args *model.CommandArgs, message string) *model.CommandResponse {
shortcutIds := [28]string{
shortcutIds := [29]string{
"api.command_shortcuts.header",
// Nav shortcuts
"api.command_shortcuts.nav.header",
@@ -58,6 +58,7 @@ func (me *ShortcutsProvider) DoCommand(args *model.CommandArgs, message string)
"api.command_shortcuts.msgs.reprint_prev",
"api.command_shortcuts.msgs.reprint_next",
"api.command_shortcuts.msgs.edit",
"api.command_shortcuts.msgs.reply",
"api.command_shortcuts.msgs.comp_username",
"api.command_shortcuts.msgs.comp_channel",
"api.command_shortcuts.msgs.comp_emoji",

View File

@@ -747,6 +747,10 @@
"id": "api.command_shortcuts.msgs.edit",
"translation": "UP (in empty input field): Edit your last message in the current channel\n"
},
{
"id": "api.command_shortcuts.msgs.reply",
"translation": "SHIFT+UP (in empty input field): Reply to the most recent message in the current channel\n"
},
{
"id": "api.command_shortcuts.msgs.header",
"translation": "#### Messages\n\n"

View File

@@ -529,6 +529,16 @@ export default class CreatePost extends React.Component {
channelId: lastPost.channel_id,
comments: PostStore.getCommentCount(lastPost)
});
} else if (!e.ctrlKey && !e.metaKey && !e.altKey && e.shiftKey && e.keyCode === KeyCodes.UP && this.state.message === '') {
e.preventDefault();
if (document.createEvent) {
var evt = document.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
document.getElementById('commentIcon0').dispatchEvent(evt);
} else if (document.createEventObject) {
var evObj = document.createEventObject();
document.getElementById('commentIcon0').fireEvent('onclick', evObj);
}
}
if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey && (e.keyCode === Constants.KeyCodes.UP || e.keyCode === Constants.KeyCodes.DOWN)) {