diff options
Diffstat (limited to 'webapp/actions')
-rw-r--r-- | webapp/actions/channel_actions.jsx | 33 | ||||
-rw-r--r-- | webapp/actions/global_actions.jsx | 11 |
2 files changed, 43 insertions, 1 deletions
diff --git a/webapp/actions/channel_actions.jsx b/webapp/actions/channel_actions.jsx index 39dc37591..78df1ff17 100644 --- a/webapp/actions/channel_actions.jsx +++ b/webapp/actions/channel_actions.jsx @@ -72,6 +72,39 @@ export function executeCommand(message, args, success, error) { msg = '/shortcuts'; } break; + case '/leave': { + // /leave command not supported in reply threads. + if (args.channel_id && (args.root_id || args.parent_id)) { + GlobalActions.sendEphemeralPost('/leave is not supported in reply threads. Use it in the center channel instead.', args.channel_id, args.parent_id); + return; + } + const channel = ChannelStore.getCurrent(); + if (channel.type === Constants.PRIVATE_CHANNEL) { + GlobalActions.showLeavePrivateChannelModal(channel); + return; + } else if ( + channel.type === Constants.DM_CHANNEL || + channel.type === Constants.GM_CHANNEL + ) { + let name; + let category; + if (channel.type === Constants.DM_CHANNEL) { + name = Utils.getUserIdFromChannelName(channel); + category = Constants.Preferences.CATEGORY_DIRECT_CHANNEL_SHOW; + } else { + name = channel.id; + category = Constants.Preferences.CATEGORY_GROUP_CHANNEL_SHOW; + } + const currentUserId = UserStore.getCurrentId(); + savePreferences(currentUserId, [{category, name, user_id: currentUserId, value: 'false'}])(dispatch, getState); + if (ChannelUtils.isFavoriteChannel(channel)) { + unmarkFavorite(channel.id); + } + browserHistory.push(`${TeamStore.getCurrentTeamRelativeUrl()}/channels/town-square`); + return; + } + break; + } case '/settings': GlobalActions.showAccountSettingsModal(); return; diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx index f464483cf..a163db126 100644 --- a/webapp/actions/global_actions.jsx +++ b/webapp/actions/global_actions.jsx @@ -281,6 +281,13 @@ export function showLeaveTeamModal() { }); } +export function showLeavePrivateChannelModal(channel) { + AppDispatcher.handleViewAction({ + type: ActionTypes.TOGGLE_LEAVE_PRIVATE_CHANNEL_MODAL, + value: channel + }); +} + export function emitSuggestionPretextChanged(suggestionId, pretext) { AppDispatcher.handleViewAction({ type: ActionTypes.SUGGESTION_PRETEXT_CHANGED, @@ -351,7 +358,7 @@ export function emitPreferencesDeletedEvent(preferences) { }); } -export function sendEphemeralPost(message, channelId) { +export function sendEphemeralPost(message, channelId, parentId) { const timestamp = Utils.getTimestamp(); const post = { id: Utils.generateId(), @@ -361,6 +368,8 @@ export function sendEphemeralPost(message, channelId) { type: Constants.PostTypes.EPHEMERAL, create_at: timestamp, update_at: timestamp, + root_id: parentId, + parent_id: parentId, props: {} }; |