diff options
-rw-r--r-- | api/command_expand_collapse.go | 19 | ||||
-rw-r--r-- | 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 afd17a6fc..d36893cb0 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 f12e19bf5..84d5be7de 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -468,6 +468,10 @@ "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" }, @@ -500,6 +504,10 @@ "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" }, |