From c249ceb10c9deb468823b7e4fa2e876be5c99545 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 1 Sep 2016 14:12:11 +0200 Subject: Reblogs fixed --- .../javascripts/components/actions/interactions.jsx | 4 +++- .../components/components/display_name.jsx | 19 +++++++++++++++++++ .../components/components/reply_indicator.jsx | 3 ++- .../javascripts/components/components/status.jsx | 20 ++++++++++++++++---- 4 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 app/assets/javascripts/components/components/display_name.jsx (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/components/actions/interactions.jsx b/app/assets/javascripts/components/actions/interactions.jsx index 281d3be87..964655530 100644 --- a/app/assets/javascripts/components/actions/interactions.jsx +++ b/app/assets/javascripts/components/actions/interactions.jsx @@ -15,7 +15,9 @@ export function reblog(status) { dispatch(reblogRequest(status)); api(getState).post(`/api/statuses/${status.get('id')}/reblog`).then(function (response) { - dispatch(reblogSuccess(status, response.data)); + // The reblog API method returns a new status wrapped around the original. In this case we are only + // interested in how the original is modified, hence passing it skipping the wrapper + dispatch(reblogSuccess(status, response.data.reblog)); }).catch(function (error) { dispatch(reblogFail(status, error)); }); diff --git a/app/assets/javascripts/components/components/display_name.jsx b/app/assets/javascripts/components/components/display_name.jsx new file mode 100644 index 000000000..1d579731b --- /dev/null +++ b/app/assets/javascripts/components/components/display_name.jsx @@ -0,0 +1,19 @@ +import ImmutablePropTypes from 'react-immutable-proptypes'; + +const DisplayName = React.createClass({ + + propTypes: { + account: ImmutablePropTypes.map.isRequired + }, + + render () { + return ( + + {this.props.account.get('display_name')} @{this.props.account.get('acct')} + + ); + } + +}); + +export default DisplayName; diff --git a/app/assets/javascripts/components/components/reply_indicator.jsx b/app/assets/javascripts/components/components/reply_indicator.jsx index 2531b7f43..9598a5874 100644 --- a/app/assets/javascripts/components/components/reply_indicator.jsx +++ b/app/assets/javascripts/components/components/reply_indicator.jsx @@ -2,6 +2,7 @@ import PureRenderMixin from 'react-addons-pure-render-mixin'; import ImmutablePropTypes from 'react-immutable-proptypes'; import Avatar from './avatar'; import IconButton from './icon_button'; +import DisplayName from './display_name'; const ReplyIndicator = React.createClass({ @@ -26,7 +27,7 @@ const ReplyIndicator = React.createClass({
- {this.props.status.getIn(['account', 'display_name'])} @{this.props.status.getIn(['account', 'acct'])} +
diff --git a/app/assets/javascripts/components/components/status.jsx b/app/assets/javascripts/components/components/status.jsx index 7885360e6..fabe85bab 100644 --- a/app/assets/javascripts/components/components/status.jsx +++ b/app/assets/javascripts/components/components/status.jsx @@ -3,6 +3,7 @@ import Avatar from './avatar'; import RelativeTimestamp from './relative_timestamp'; import PureRenderMixin from 'react-addons-pure-render-mixin'; import IconButton from './icon_button'; +import DisplayName from './display_name'; const Status = React.createClass({ @@ -29,7 +30,20 @@ const Status = React.createClass({ render () { var content = { __html: this.props.status.get('content') }; - var status = this.props.status; + var { status, ...other } = this.props; + + if (status.get('reblog') !== null) { + return ( +
+
+
+ {status.getIn(['account', 'display_name'])} reblogged +
+ + +
+ ); + } return (
@@ -43,9 +57,7 @@ const Status = React.createClass({
- - {status.getIn(['account', 'display_name'])} @{status.getIn(['account', 'acct'])} - + -- cgit