From 1fce687f8e03d78b4b842422fc6621bba439e1cd Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 2 Oct 2016 15:14:26 +0200 Subject: Unreblogging and unfavouriting from the UI --- .../components/features/account/index.jsx | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'app/assets/javascripts/components/features/account/index.jsx') diff --git a/app/assets/javascripts/components/features/account/index.jsx b/app/assets/javascripts/components/features/account/index.jsx index db0925d78..40c06c545 100644 --- a/app/assets/javascripts/components/features/account/index.jsx +++ b/app/assets/javascripts/components/features/account/index.jsx @@ -10,7 +10,12 @@ import { } from '../../actions/accounts'; import { deleteStatus } from '../../actions/statuses'; import { replyCompose } from '../../actions/compose'; -import { favourite, reblog } from '../../actions/interactions'; +import { + favourite, + reblog, + unreblog, + unfavourite +} from '../../actions/interactions'; import Header from './components/header'; import { selectStatus, @@ -54,11 +59,11 @@ const Account = React.createClass({ }, handleFollow () { - this.props.dispatch(followAccount(this.props.account.get('id'))); - }, - - handleUnfollow () { - this.props.dispatch(unfollowAccount(this.props.account.get('id'))); + if (this.props.account.getIn(['relationship', 'following'])) { + this.props.dispatch(unfollowAccount(this.props.account.get('id'))); + } else { + this.props.dispatch(followAccount(this.props.account.get('id'))); + } }, handleReply (status) { @@ -66,11 +71,19 @@ const Account = React.createClass({ }, handleReblog (status) { - this.props.dispatch(reblog(status)); + if (status.get('reblogged')) { + this.props.dispatch(unreblog(status)); + } else { + this.props.dispatch(reblog(status)); + } }, handleFavourite (status) { - this.props.dispatch(favourite(status)); + if (status.get('favourited')) { + this.props.dispatch(unfavourite(status)); + } else { + this.props.dispatch(favourite(status)); + } }, handleDelete (status) { -- cgit