From a62e2e09e8dae45572e9c12eda9b05dcf74ee56d Mon Sep 17 00:00:00 2001 From: igoradamenko Date: Sun, 18 Mar 2018 23:22:42 +0200 Subject: [PATCH] reload comments if someone was unblocked --- .../components/blocked-users/blocked-users.jsx | 4 ++++ web/app/components/root/root.jsx | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/web/app/components/blocked-users/blocked-users.jsx b/web/app/components/blocked-users/blocked-users.jsx index 7d0d84a9..ead8a501 100644 --- a/web/app/components/blocked-users/blocked-users.jsx +++ b/web/app/components/blocked-users/blocked-users.jsx @@ -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); }); } } diff --git a/web/app/components/root/root.jsx b/web/app/components/root/root.jsx index ea6f1e81..e576a7ff 100644 --- a/web/app/components/root/root.jsx +++ b/web/app/components/root/root.jsx @@ -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 && (
- +
) }