diff options
Diffstat (limited to 'src/components/post_status_form')
| -rw-r--r-- | src/components/post_status_form/post_status_form.js | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 0944d841..0d4d87f2 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -1,12 +1,40 @@ import statusPoster from '../../services/status_poster/status_poster.service.js' +import { reject, map, uniqBy } from 'lodash'; + +const buildMentionsString = ({user, attentions}, currentUser) => { + + let allAttentions = [...attentions] + + allAttentions.unshift(user) + + allAttentions = uniqBy(allAttentions, 'id') + allAttentions = reject(allAttentions, {id: currentUser.id}) + + let mentions = map(allAttentions, (attention) => { + return `@${attention.screen_name}` + }) + + return mentions.join(' ') + ' ' +} const PostStatusForm = { props: [ - 'replyTo' + 'replyTo', + 'repliedUser', + 'attentions' ], data () { + let statusText = '' + + if (this.replyTo) { + const currentUser = this.$store.state.users.currentUser + statusText = buildMentionsString({ user: this.repliedUser, attentions: this.attentions }, currentUser) + } + return { - newStatus: { } + newStatus: { + status: statusText + } } }, methods: { |
