Add completion for groups.

This commit is contained in:
eal 2017-11-20 16:46:23 +02:00
parent a284a52306
commit cd87a6712d
2 changed files with 15 additions and 1 deletions

View file

@ -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: {

View file

@ -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)