diff --git a/app/assets/javascripts/components/features/ui/containers/compose_form_container.jsx b/app/assets/javascripts/components/features/ui/containers/compose_form_container.jsx
index a092a1e8e58..b9c22a19d38 100644
--- a/app/assets/javascripts/components/features/ui/containers/compose_form_container.jsx
+++ b/app/assets/javascripts/components/features/ui/containers/compose_form_container.jsx
@@ -1,25 +1,13 @@
import { connect } from 'react-redux';
import ComposeForm from '../components/compose_form';
import { changeCompose, submitCompose, cancelReplyCompose } from '../../../actions/compose';
-
-function selectStatus(state) {
- let statusId = state.getIn(['compose', 'in_reply_to'], null);
-
- if (statusId === null) {
- return null;
- }
-
- let status = state.getIn(['timelines', 'statuses', statusId]);
- status = status.set('account', state.getIn(['timelines', 'accounts', status.get('account')]));
-
- return status;
-};
+import { selectStatus } from '../../../reducers/timelines';
const mapStateToProps = function (state, props) {
return {
text: state.getIn(['compose', 'text']),
is_submitting: state.getIn(['compose', 'is_submitting']),
- in_reply_to: selectStatus(state)
+ in_reply_to: selectStatus(state, state.getIn(['compose', 'in_reply_to']))
};
};
diff --git a/app/assets/javascripts/components/reducers/compose.jsx b/app/assets/javascripts/components/reducers/compose.jsx
index 688c494c073..3974e40c649 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 => {
diff --git a/app/views/api/statuses/show.rabl b/app/views/api/statuses/show.rabl
index 2f30f68ccaa..f06aa6e74c0 100644
--- a/app/views/api/statuses/show.rabl
+++ b/app/views/api/statuses/show.rabl
@@ -20,6 +20,12 @@ end
child :media_attachments, object_root: false do
attributes :id, :remote_url, :type
- node(:url) { |media| full_asset_url(media.file.url) }
+ node(:url) { |media| full_asset_url(media.file.url) }
node(:preview_url) { |media| full_asset_url(media.file.url(:small)) }
end
+
+child :mentions, object_root: false do
+ node(:url) { |mention| TagManager.instance.url_for(mention.account) }
+ node(:acct) { |mention| mention.account.acct }
+ node(:id) { |mention| mention.account_id }
+end