Change output of api/accounts/:id/follow and unfollow to return relationship
Track relationship in redux state. Display follow/unfollow and following-back information on account view (unstyled)
This commit is contained in:
@ -14,15 +14,24 @@ const StatusContent = React.createClass({
|
||||
mixins: [PureRenderMixin],
|
||||
|
||||
componentDidMount () {
|
||||
const node = ReactDOM.findDOMNode(this);
|
||||
const node = ReactDOM.findDOMNode(this);
|
||||
const links = node.querySelectorAll('a');
|
||||
|
||||
this.props.status.get('mentions').forEach(mention => {
|
||||
const links = node.querySelector(`a[href="${mention.get('url')}"]`);
|
||||
links.addEventListener('click', this.onLinkClick.bind(this, mention));
|
||||
});
|
||||
for (var i = 0; i < links.length; ++i) {
|
||||
let link = links[i];
|
||||
let mention = this.props.status.get('mentions').find(item => link.href === item.get('url'));
|
||||
|
||||
if (mention) {
|
||||
link.addEventListener('click', this.onMentionClick.bind(this, mention));
|
||||
} else {
|
||||
link.setAttribute('target', '_blank');
|
||||
link.setAttribute('rel', 'noopener');
|
||||
link.addEventListener('click', this.onNormalClick);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onLinkClick (mention, e) {
|
||||
onMentionClick (mention, e) {
|
||||
if (e.button === 0) {
|
||||
e.preventDefault();
|
||||
this.context.router.push(`/accounts/${mention.get('id')}`);
|
||||
@ -31,6 +40,10 @@ const StatusContent = React.createClass({
|
||||
e.stopPropagation();
|
||||
},
|
||||
|
||||
onNormalClick (e) {
|
||||
e.stopPropagation();
|
||||
},
|
||||
|
||||
render () {
|
||||
const content = { __html: this.props.status.get('content') };
|
||||
return <div className='status__content' dangerouslySetInnerHTML={content} />;
|
||||
|
Reference in New Issue
Block a user