From bc98865c1a97a350d98c1c295f6d67ef69ba5eb5 Mon Sep 17 00:00:00 2001
From: Eugen Rochko <eugen@zeonfederated.com>
Date: Thu, 22 Sep 2016 00:09:21 +0200
Subject: API returns mentions for statuses, compose form pre-fills all
 relevant usernames into the form when replying

---
 app/assets/javascripts/components/reducers/compose.jsx | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'app/assets/javascripts/components/reducers/compose.jsx')

diff --git a/app/assets/javascripts/components/reducers/compose.jsx b/app/assets/javascripts/components/reducers/compose.jsx
index 688c494c0..3974e40c6 100644
--- a/app/assets/javascripts/components/reducers/compose.jsx
+++ b/app/assets/javascripts/components/reducers/compose.jsx
@@ -23,6 +23,10 @@ const initialState = Immutable.Map({
   media_attachments: Immutable.List([])
 });
 
+function statusToTextMentions(status) {
+  return Immutable.OrderedSet([`@${status.getIn(['account', 'acct'])} `]).union(status.get('mentions').map(mention => `@${mention.get('acct')} `)).join('');
+};
+
 export default function compose(state = initialState, action) {
   switch(action.type) {
     case COMPOSE_CHANGE:
@@ -30,7 +34,7 @@ export default function compose(state = initialState, action) {
     case COMPOSE_REPLY:
       return state.withMutations(map => {
         map.set('in_reply_to', action.status.get('id'));
-        map.set('text', `@${action.status.getIn(['account', 'acct'])} `);
+        map.set('text', statusToTextMentions(action.status));
       });
     case COMPOSE_REPLY_CANCEL:
       return state.withMutations(map => {
-- 
cgit 

