From b5fcfd608c0e9ef764cace7328653e4d4c47a061 Mon Sep 17 00:00:00 2001 From: Yusuke Nemoto Date: Mon, 12 Dec 2016 14:26:53 +0900 Subject: [PATCH] gh-4759 add system message feedbak for expand/collapse command (#4761) --- api/command_expand_collapse.go | 19 ++++++++++++++----- i18n/en.json | 8 ++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/api/command_expand_collapse.go b/api/command_expand_collapse.go index afd17a6fc7..d36893cb0d 100644 --- a/api/command_expand_collapse.go +++ b/api/command_expand_collapse.go @@ -4,6 +4,8 @@ package api import ( + "strconv" + "github.com/mattermost/platform/model" ) @@ -50,19 +52,19 @@ func (me *CollapseProvider) GetCommand(c *Context) *model.Command { } func (me *ExpandProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { - return setCollapsePreference(c, "false") + return setCollapsePreference(c, false) } func (me *CollapseProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { - return setCollapsePreference(c, "true") + return setCollapsePreference(c, true) } -func setCollapsePreference(c *Context, value string) *model.CommandResponse { +func setCollapsePreference(c *Context, isCollapse bool) *model.CommandResponse { pref := model.Preference{ UserId: c.Session.UserId, Category: model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS, Name: model.PREFERENCE_NAME_COLLAPSE_SETTING, - Value: value, + Value: strconv.FormatBool(isCollapse), } if result := <-Srv.Store.Preference().Save(&model.Preferences{pref}); result.Err != nil { @@ -73,5 +75,12 @@ func setCollapsePreference(c *Context, value string) *model.CommandResponse { socketMessage.Add("preference", pref.ToJson()) go Publish(socketMessage) - return &model.CommandResponse{} + var rmsg string + + if isCollapse { + rmsg = c.T("api.command_collapse.success") + } else { + rmsg = c.T("api.command_expand.success") + } + return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: rmsg} } diff --git a/i18n/en.json b/i18n/en.json index f12e19bf5f..84d5be7de2 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -467,6 +467,10 @@ "id": "api.command_collapse.name", "translation": "collapse" }, + { + "id": "api.command_collapse.success", + "translation": "Image links now collapse by default" + }, { "id": "api.command_echo.create.app_error", "translation": "Unable to create /echo post, err=%v" @@ -499,6 +503,10 @@ "id": "api.command_expand.name", "translation": "expand" }, + { + "id": "api.command_expand.success", + "translation": "Image links now expand by default" + }, { "id": "api.command_expand_collapse.fail.app_error", "translation": "An error occured while expanding previews"