diff options
Diffstat (limited to 'webapp/utils')
-rw-r--r-- | webapp/utils/async_client.jsx | 6 | ||||
-rw-r--r-- | webapp/utils/client.jsx | 5 | ||||
-rw-r--r-- | webapp/utils/constants.jsx | 4 | ||||
-rw-r--r-- | webapp/utils/text_formatting.jsx | 5 |
4 files changed, 15 insertions, 5 deletions
diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx index 9c40311cf..9a5869f9a 100644 --- a/webapp/utils/async_client.jsx +++ b/webapp/utils/async_client.jsx @@ -755,12 +755,12 @@ export function savePreferences(preferences, success, error) { ); } -export function getSuggestedCommands(command, suggestionId, component) { - client.listCommands( +export function getSuggestedCommands(command, channelId, suggestionId, component) { + client.listCommands({command: command, channelId: channelId}, (data) => { var matches = []; data.forEach((cmd) => { - if (('/' + cmd.trigger).indexOf(command) === 0) { + if (('/' + cmd.trigger).indexOf(command) === 0 || cmd.external_management) { let s = '/' + cmd.trigger; let hint = ''; if (cmd.auto_complete_hint && cmd.auto_complete_hint.length !== 0) { diff --git a/webapp/utils/client.jsx b/webapp/utils/client.jsx index 9bd62e22d..ef6d496a2 100644 --- a/webapp/utils/client.jsx +++ b/webapp/utils/client.jsx @@ -1002,12 +1002,13 @@ export function regenCommandToken(data, success, error) { }); } -export function listCommands(success, error) { +export function listCommands(data, success, error) { $.ajax({ url: '/api/v1/commands/list', dataType: 'json', contentType: 'application/json', - type: 'GET', + type: 'POST', + data: JSON.stringify(data), success, error: function onError(xhr, status, err) { var e = handleError('listCommands', xhr, status, err); diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx index 32123e369..c1e527702 100644 --- a/webapp/utils/constants.jsx +++ b/webapp/utils/constants.jsx @@ -560,6 +560,10 @@ export default { EMBED_TOGGLE: { label: 'embed_toggle', description: 'Show toggle for all embed previews' + }, + SLASHCMD_AUTOCMP: { + label: 'slashCmd_autocmp', + description: 'Enable external application to offer slash command autocomplete' } }, OVERLAY_TIME_DELAY: 400, diff --git a/webapp/utils/text_formatting.jsx b/webapp/utils/text_formatting.jsx index 9833b995c..4c8b5e24c 100644 --- a/webapp/utils/text_formatting.jsx +++ b/webapp/utils/text_formatting.jsx @@ -213,6 +213,11 @@ function highlightCurrentMentions(text, tokens) { } for (const mention of UserStore.getCurrentMentionKeys()) { + // occasionally we get an empty mention which matches a bunch of empty strings + if (!mention) { + continue; + } + output = output.replace(new RegExp(`(^|\\W)(${escapeRegex(mention)})\\b`, 'gi'), replaceCurrentMentionWithToken); } |