aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2016-11-03 17:17:32 +0100
committerRoger Braun <roger@rogerbraun.net>2016-11-03 17:17:32 +0100
commit9ff8bf4c143f849635d64f5d0344ff999908fe34 (patch)
tree126998b31d60a2cd756b2e0460884aeb54001be8 /src
parent7e2c52b12cf6883f32716230b0fdcdad7a26632b (diff)
Make mention strings work.
Diffstat (limited to 'src')
-rw-r--r--src/components/post_status_form/post_status_form.js32
-rw-r--r--src/components/status/status.vue2
2 files changed, 31 insertions, 3 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: {
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 @@
<favorite-button :status=status></favorite-button>
</div>
- <post-status-form v-if="replying" :reply-to="status.id"></post-status-form>
+ <post-status-form v-if="replying" :reply-to="status.id" :attentions="status.attentions" :repliedUser="status.user"></post-status-form>
</div>
</div>
</div>