diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 6fc84407..30c054b0 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -74,6 +74,17 @@ const PostStatusForm = { name: '', img: image_url })) + } else if (firstchar === '!') { + const matchedGroups = filter(this.groups, (group) => group.nickname.match(this.textAtCaret.slice(1))) + if (matchedGroups.length <= 0) { + return false + } + return map(take(matchedGroups, 5), ({nickname, original_logo}) => ({ + // eslint-disable-next-line camelcase + screen_name: `!${nickname}`, + name: '', + img: original_logo || 'https://placehold.it/48x48' + })) } else { return false } @@ -90,6 +101,9 @@ const PostStatusForm = { }, emoji () { return this.$store.state.config.emoji || [] + }, + groups () { + return this.$store.state.groups.groups } }, methods: { diff --git a/src/services/completion/completion.js b/src/services/completion/completion.js index 11c45867..3eeefd34 100644 --- a/src/services/completion/completion.js +++ b/src/services/completion/completion.js @@ -37,7 +37,7 @@ export const addPositionToWords = (words) => { export const splitIntoWords = (str) => { // Split at word boundaries const regex = /\b/ - const triggers = /[@#:]+$/ + const triggers = /[@#:!]+$/ let split = str.split(regex)