mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-26 22:31:13 +00:00
Merge branch 'main' into feature/add-ids-and-classes
This commit is contained in:
commit
6a9b936d08
3 changed files with 25 additions and 43 deletions
|
@ -647,6 +647,12 @@ export class Community extends Component<
|
||||||
const blockCommunityRes = await HttpService.client.blockCommunity(form);
|
const blockCommunityRes = await HttpService.client.blockCommunity(form);
|
||||||
if (blockCommunityRes.state == "success") {
|
if (blockCommunityRes.state == "success") {
|
||||||
updateCommunityBlock(blockCommunityRes.data);
|
updateCommunityBlock(blockCommunityRes.data);
|
||||||
|
this.setState(s => {
|
||||||
|
if (s.communityRes.state == "success") {
|
||||||
|
s.communityRes.data.community_view.blocked =
|
||||||
|
blockCommunityRes.data.blocked;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,6 @@ interface SidebarState {
|
||||||
removeCommunityLoading: boolean;
|
removeCommunityLoading: boolean;
|
||||||
leaveModTeamLoading: boolean;
|
leaveModTeamLoading: boolean;
|
||||||
followCommunityLoading: boolean;
|
followCommunityLoading: boolean;
|
||||||
blockCommunityLoading: boolean;
|
|
||||||
purgeCommunityLoading: boolean;
|
purgeCommunityLoading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +77,6 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
removeCommunityLoading: false,
|
removeCommunityLoading: false,
|
||||||
leaveModTeamLoading: false,
|
leaveModTeamLoading: false,
|
||||||
followCommunityLoading: false,
|
followCommunityLoading: false,
|
||||||
blockCommunityLoading: false,
|
|
||||||
purgeCommunityLoading: false,
|
purgeCommunityLoading: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -105,7 +103,6 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
removeCommunityLoading: false,
|
removeCommunityLoading: false,
|
||||||
leaveModTeamLoading: false,
|
leaveModTeamLoading: false,
|
||||||
followCommunityLoading: false,
|
followCommunityLoading: false,
|
||||||
blockCommunityLoading: false,
|
|
||||||
purgeCommunityLoading: false,
|
purgeCommunityLoading: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -376,35 +373,18 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
blockCommunity() {
|
blockCommunity() {
|
||||||
const community_view = this.props.community_view;
|
const { subscribed, blocked } = this.props.community_view;
|
||||||
const blocked = this.props.community_view.blocked;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mb-2">
|
<div className="mb-2">
|
||||||
{community_view.subscribed == "NotSubscribed" &&
|
{subscribed == "NotSubscribed" && (
|
||||||
(blocked ? (
|
|
||||||
<button
|
<button
|
||||||
className="btn btn-danger btn-block"
|
className="btn btn-danger btn-block"
|
||||||
onClick={linkEvent(this, this.handleBlockCommunity)}
|
onClick={linkEvent(this, this.handleBlockCommunity)}
|
||||||
>
|
>
|
||||||
{this.state.blockCommunityLoading ? (
|
{i18n.t(blocked ? "unblock_community" : "block_community")}
|
||||||
<Spinner />
|
|
||||||
) : (
|
|
||||||
i18n.t("unblock_community")
|
|
||||||
)}
|
|
||||||
</button>
|
</button>
|
||||||
) : (
|
|
||||||
<button
|
|
||||||
className="btn btn-danger btn-block"
|
|
||||||
onClick={linkEvent(this, this.handleBlockCommunity)}
|
|
||||||
>
|
|
||||||
{this.state.blockCommunityLoading ? (
|
|
||||||
<Spinner />
|
|
||||||
) : (
|
|
||||||
i18n.t("block_community")
|
|
||||||
)}
|
)}
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -668,10 +648,11 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleBlockCommunity(i: Sidebar) {
|
handleBlockCommunity(i: Sidebar) {
|
||||||
i.setState({ blockCommunityLoading: true });
|
const { community, blocked } = i.props.community_view;
|
||||||
|
|
||||||
i.props.onBlockCommunity({
|
i.props.onBlockCommunity({
|
||||||
community_id: 0,
|
community_id: community.id,
|
||||||
block: !i.props.community_view.blocked,
|
block: !blocked,
|
||||||
auth: myAuthRequired(),
|
auth: myAuthRequired(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -730,19 +730,14 @@ export class Post extends Component<any, PostState> {
|
||||||
|
|
||||||
async handleBlockCommunity(form: BlockCommunity) {
|
async handleBlockCommunity(form: BlockCommunity) {
|
||||||
const blockCommunityRes = await HttpService.client.blockCommunity(form);
|
const blockCommunityRes = await HttpService.client.blockCommunity(form);
|
||||||
// TODO Probably isn't necessary
|
|
||||||
this.setState(s => {
|
|
||||||
if (
|
|
||||||
s.postRes.state == "success" &&
|
|
||||||
blockCommunityRes.state == "success"
|
|
||||||
) {
|
|
||||||
s.postRes.data.community_view = blockCommunityRes.data.community_view;
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (blockCommunityRes.state == "success") {
|
if (blockCommunityRes.state == "success") {
|
||||||
updateCommunityBlock(blockCommunityRes.data);
|
updateCommunityBlock(blockCommunityRes.data);
|
||||||
|
this.setState(s => {
|
||||||
|
if (s.postRes.state == "success") {
|
||||||
|
s.postRes.data.community_view.blocked =
|
||||||
|
blockCommunityRes.data.blocked;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue