reload comments if someone was unblocked
This commit is contained in:
@@ -19,6 +19,8 @@ export default class BlockedUsers extends Component {
|
||||
if (confirm('Do you want to block this user?')) {
|
||||
api.blockUser({ id: user.id }).then(() => {
|
||||
this.setState({ unblockedUsers: this.state.unblockedUsers.filter(x => x !== user.id) });
|
||||
|
||||
if (this.props.onUnblock) this.props.onUnblock(user.id);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -27,6 +29,8 @@ export default class BlockedUsers extends Component {
|
||||
if (confirm('Do you want to unblock this user?')) {
|
||||
api.unblockUser({ id: user.id }).then(() => {
|
||||
this.setState({ unblockedUsers: this.state.unblockedUsers.concat([user.id]) });
|
||||
|
||||
if (this.props.onUnblock) this.props.onUnblock(user.id);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,19 @@ export default class Root extends Component {
|
||||
}
|
||||
|
||||
onBlockedUsersHide() {
|
||||
this.setState({ isBlockedVisible: false });
|
||||
// if someone was unblocked let's reload comments
|
||||
if (this.state.wasSomeoneUnblocked) {
|
||||
api.find({ url }).then(({ comments } = {}) => store.set('comments', comments));
|
||||
}
|
||||
|
||||
this.setState({
|
||||
isBlockedVisible: false,
|
||||
wasSomeoneUnblocked: false,
|
||||
});
|
||||
}
|
||||
|
||||
onUnblockSomeone() {
|
||||
this.setState({ wasSomeoneUnblocked: true });
|
||||
}
|
||||
|
||||
addComment(data) {
|
||||
@@ -197,7 +209,7 @@ export default class Root extends Component {
|
||||
{
|
||||
isBlockedVisible && (
|
||||
<div className="root__main">
|
||||
<BlockedUsers users={bannedUsers}/>
|
||||
<BlockedUsers users={bannedUsers} onUnblock={this.onUnblockSomeone}/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user