diff options
| author | Roger Braun <roger@rogerbraun.net> | 2016-11-05 10:55:15 +0100 |
|---|---|---|
| committer | Roger Braun <roger@rogerbraun.net> | 2016-11-05 10:55:15 +0100 |
| commit | 82d023609bd20a5616c9773842cb8fb4d51dfdb7 (patch) | |
| tree | cbeb764d369f0c6461f5251feb1bbbfc88f04ec9 /src/components/post_status_form | |
| parent | 88d960b9f6109c0c57958fb74d841dab9954ac33 (diff) | |
| parent | 572aceb7e7a86c227f2d92c0abf651ba9c3cb4df (diff) | |
Merge branch 'master' of ssh.gitgud.io:lambadalambda/pleroma-fe
Diffstat (limited to 'src/components/post_status_form')
| -rw-r--r-- | src/components/post_status_form/post_status_form.js | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 596c9f58..2c015154 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -1,18 +1,51 @@ 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 = { - data() { + props: [ + '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: { - postStatus(newStatus) { + postStatus (newStatus) { statusPoster.postStatus({ status: newStatus.status, - store: this.$store + store: this.$store, + inReplyToStatusId: this.replyTo }) this.newStatus = { } + this.$emit('posted') } } } |
