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: '', name: '',
img: image_url 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 { } else {
return false return false
} }
@ -90,6 +101,9 @@ const PostStatusForm = {
}, },
emoji () { emoji () {
return this.$store.state.config.emoji || [] return this.$store.state.config.emoji || []
},
groups () {
return this.$store.state.groups.groups
} }
}, },
methods: { methods: {

View File

@ -37,7 +37,7 @@ export const addPositionToWords = (words) => {
export const splitIntoWords = (str) => { export const splitIntoWords = (str) => {
// Split at word boundaries // Split at word boundaries
const regex = /\b/ const regex = /\b/
const triggers = /[@#:]+$/ const triggers = /[@#:!]+$/
let split = str.split(regex) let split = str.split(regex)