removeCommunityLoading: boolean;
leaveModTeamLoading: boolean;
followCommunityLoading: boolean;
- blockCommunityLoading: boolean;
purgeCommunityLoading: boolean;
}
removeCommunityLoading: false,
leaveModTeamLoading: false,
followCommunityLoading: false,
- blockCommunityLoading: false,
purgeCommunityLoading: false,
};
removeCommunityLoading: false,
leaveModTeamLoading: false,
followCommunityLoading: false,
- blockCommunityLoading: false,
purgeCommunityLoading: false,
});
}
}
blockCommunity() {
- const community_view = this.props.community_view;
- const blocked = this.props.community_view.blocked;
+ const { subscribed, blocked } = this.props.community_view;
return (
<div className="mb-2">
- {community_view.subscribed == "NotSubscribed" &&
- (blocked ? (
- <button
- className="btn btn-danger btn-block"
- onClick={linkEvent(this, this.handleBlockCommunity)}
- >
- {this.state.blockCommunityLoading ? (
- <Spinner />
- ) : (
- i18n.t("unblock_community")
- )}
- </button>
- ) : (
- <button
- className="btn btn-danger btn-block"
- onClick={linkEvent(this, this.handleBlockCommunity)}
- >
- {this.state.blockCommunityLoading ? (
- <Spinner />
- ) : (
- i18n.t("block_community")
- )}
- </button>
- ))}
+ {subscribed == "NotSubscribed" && (
+ <button
+ className="btn btn-danger btn-block"
+ onClick={linkEvent(this, this.handleBlockCommunity)}
+ >
+ {i18n.t(blocked ? "unblock_community" : "block_community")}
+ </button>
+ )}
</div>
);
}
}
handleBlockCommunity(i: Sidebar) {
- i.setState({ blockCommunityLoading: true });
+ const { community, blocked } = i.props.community_view;
+
i.props.onBlockCommunity({
- community_id: 0,
- block: !i.props.community_view.blocked,
+ community_id: community.id,
+ block: !blocked,
auth: myAuthRequired(),
});
}