From 7e2c52b12cf6883f32716230b0fdcdad7a26632b Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Thu, 3 Nov 2016 16:59:27 +0100 Subject: Add replies. --- src/components/post_status_form/post_status_form.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/components/post_status_form') diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 596c9f58..0944d841 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -1,16 +1,20 @@ import statusPoster from '../../services/status_poster/status_poster.service.js' const PostStatusForm = { - data() { + props: [ + 'replyTo' + ], + data () { return { newStatus: { } } }, methods: { - postStatus(newStatus) { + postStatus (newStatus) { statusPoster.postStatus({ status: newStatus.status, - store: this.$store + store: this.$store, + inReplyToStatusId: this.replyTo }) this.newStatus = { } } -- cgit v1.2.3-70-g09d2 From 9ff8bf4c143f849635d64f5d0344ff999908fe34 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Thu, 3 Nov 2016 17:17:32 +0100 Subject: Make mention strings work. --- .../post_status_form/post_status_form.js | 32 ++++++++++++++++++++-- src/components/status/status.vue | 2 +- 2 files changed, 31 insertions(+), 3 deletions(-) (limited to 'src/components/post_status_form') 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: { diff --git a/src/components/status/status.vue b/src/components/status/status.vue index ab827325..f3d36c54 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -45,7 +45,7 @@ - + -- cgit v1.2.3-70-g09d2 From 572aceb7e7a86c227f2d92c0abf651ba9c3cb4df Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Thu, 3 Nov 2016 17:35:49 +0100 Subject: Hide after posting. --- src/components/post_status_form/post_status_form.js | 1 + src/components/status/status.vue | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/components/post_status_form') diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 0d4d87f2..2c015154 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -45,6 +45,7 @@ const PostStatusForm = { inReplyToStatusId: this.replyTo }) this.newStatus = { } + this.$emit('posted') } } } diff --git a/src/components/status/status.vue b/src/components/status/status.vue index f3d36c54..8361aa52 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -35,7 +35,7 @@
@@ -45,7 +45,7 @@
- +
-- cgit v1.2.3-70-g09d2