From 2294936595355703afba14a91adb73c321abf8ac Mon Sep 17 00:00:00 2001 From: Yusuke Nemoto Date: Wed, 28 Dec 2016 22:46:11 +0900 Subject: PLT-4648 break `/shortcuts` block (#4829) --- api/command_shortcuts.go | 56 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 10 deletions(-) (limited to 'api') diff --git a/api/command_shortcuts.go b/api/command_shortcuts.go index f75b419b1..1664221c1 100644 --- a/api/command_shortcuts.go +++ b/api/command_shortcuts.go @@ -36,23 +36,59 @@ func (me *ShortcutsProvider) GetCommand(c *Context) *model.Command { } func (me *ShortcutsProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { - shortcutIds := [4]string{ - "api.command_shortcuts.nav", - "api.command_shortcuts.files", - "api.command_shortcuts.msgs", - "api.command_shortcuts.browser", + shortcutIds := [28]string{ + "api.command_shortcuts.header", + // Nav shortcuts + "api.command_shortcuts.nav.header", + "api.command_shortcuts.nav.prev", + "api.command_shortcuts.nav.next", + "api.command_shortcuts.nav.unread_prev", + "api.command_shortcuts.nav.unread_next", + "api.command_shortcuts.nav.switcher", + "api.command_shortcuts.nav.settings", + "api.command_shortcuts.nav.recent_mentions", + // Files shortcuts + "api.command_shortcuts.files.header", + "api.command_shortcuts.files.upload", + // Msg shortcuts + "api.command_shortcuts.msgs.header", + "api.command_shortcuts.msgs.mark_as_read", + "api.command_shortcuts.msgs.reprint_prev", + "api.command_shortcuts.msgs.reprint_next", + "api.command_shortcuts.msgs.edit", + "api.command_shortcuts.msgs.comp_username", + "api.command_shortcuts.msgs.comp_channel", + "api.command_shortcuts.msgs.comp_emoji", + // Browser shortcuts + "api.command_shortcuts.browser.header", + "api.command_shortcuts.browser.channel_prev", + "api.command_shortcuts.browser.channel_next", + "api.command_shortcuts.browser.font_increase", + "api.command_shortcuts.browser.font_decrease", + "api.command_shortcuts.browser.highlight_prev", + "api.command_shortcuts.browser.highlight_next", + "api.command_shortcuts.browser.newline", } - var buffer bytes.Buffer + var osDependentWords map[string]interface{} if strings.Contains(message, "mac") { - for _, element := range shortcutIds { - buffer.WriteString(c.T(element + "_mac")) + osDependentWords = map[string]interface{}{ + "CmdOrCtrl": c.T("api.command_shortcuts.cmd"), + "ChannelPrevCmd": c.T("api.command_shortcuts.browser.channel_prev.cmd_mac"), + "ChannelNextCmd": c.T("api.command_shortcuts.browser.channel_next.cmd_mac"), } } else { - for _, element := range shortcutIds { - buffer.WriteString(c.T(element)) + osDependentWords = map[string]interface{}{ + "CmdOrCtrl": c.T("api.command_shortcuts.ctrl"), + "ChannelPrevCmd": c.T("api.command_shortcuts.browser.channel_prev.cmd"), + "ChannelNextCmd": c.T("api.command_shortcuts.browser.channel_next.cmd"), } } + var buffer bytes.Buffer + for _, element := range shortcutIds { + buffer.WriteString(c.T(element, osDependentWords)) + } + return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: buffer.String()} } -- cgit v1.2.3-1-g7c22