X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fshared%2Fcomponents%2Fcommunity%2Fsidebar.tsx;h=a5c620f3b4b5704e8763a4d549af8fbd97c877d8;hb=2b1af707c3df6126b3e6890106c03c60ad49b1be;hp=d592571c5a83604edfcd9581295e4efeeaa7fc40;hpb=f61037f5d89f12818c8100f907a98b74e980112a;p=lemmy-ui.git diff --git a/src/shared/components/community/sidebar.tsx b/src/shared/components/community/sidebar.tsx index d592571..a5c620f 100644 --- a/src/shared/components/community/sidebar.tsx +++ b/src/shared/components/community/sidebar.tsx @@ -1,4 +1,4 @@ -import { Component, linkEvent } from "inferno"; +import { Component, InfernoNode, linkEvent } from "inferno"; import { Link } from "inferno-router"; import { AddModToCommunity, @@ -6,6 +6,7 @@ import { CommunityModeratorView, CommunityView, DeleteCommunity, + EditCommunity, FollowCommunity, Language, PersonView, @@ -13,7 +14,7 @@ import { RemoveCommunity, } from "lemmy-js-client"; import { i18n } from "../../i18next"; -import { UserService, WebSocketService } from "../../services"; +import { UserService } from "../../services"; import { amAdmin, amMod, @@ -21,9 +22,8 @@ import { getUnixTime, hostname, mdToHtml, - myAuth, + myAuthRequired, numToSI, - wsClient, } from "../../utils"; import { BannerIconHeader } from "../common/banner-icon-header"; import { Icon, PurgeWarning, Spinner } from "../common/icon"; @@ -42,6 +42,13 @@ interface SidebarProps { enableNsfw?: boolean; showIcon?: boolean; editable?: boolean; + onDeleteCommunity(form: DeleteCommunity): void; + onRemoveCommunity(form: RemoveCommunity): void; + onLeaveModTeam(form: AddModToCommunity): void; + onFollowCommunity(form: FollowCommunity): void; + onBlockCommunity(form: BlockCommunity): void; + onPurgeCommunity(form: PurgeCommunity): void; + onEditCommunity(form: EditCommunity): void; } interface SidebarState { @@ -51,8 +58,13 @@ interface SidebarState { showRemoveDialog: boolean; showPurgeDialog: boolean; purgeReason?: string; - purgeLoading: boolean; showConfirmLeaveModTeam: boolean; + deleteCommunityLoading: boolean; + removeCommunityLoading: boolean; + leaveModTeamLoading: boolean; + followCommunityLoading: boolean; + blockCommunityLoading: boolean; + purgeCommunityLoading: boolean; } export class Sidebar extends Component { @@ -60,16 +72,44 @@ export class Sidebar extends Component { showEdit: false, showRemoveDialog: false, showPurgeDialog: false, - purgeLoading: false, showConfirmLeaveModTeam: false, + deleteCommunityLoading: false, + removeCommunityLoading: false, + leaveModTeamLoading: false, + followCommunityLoading: false, + blockCommunityLoading: false, + purgeCommunityLoading: false, }; constructor(props: any, context: any) { super(props, context); - this.handleEditCommunity = this.handleEditCommunity.bind(this); this.handleEditCancel = this.handleEditCancel.bind(this); } + componentWillReceiveProps( + nextProps: Readonly<{ children?: InfernoNode } & SidebarProps> + ): void { + if (this.props.moderators != nextProps.moderators) { + this.setState({ + showConfirmLeaveModTeam: false, + }); + } + + if (this.props.community_view != nextProps.community_view) { + this.setState({ + showEdit: false, + showPurgeDialog: false, + showRemoveDialog: false, + deleteCommunityLoading: false, + removeCommunityLoading: false, + leaveModTeamLoading: false, + followCommunityLoading: false, + blockCommunityLoading: false, + purgeCommunityLoading: false, + }); + } + } + render() { return (
@@ -81,7 +121,7 @@ export class Sidebar extends Component { allLanguages={this.props.allLanguages} siteLanguages={this.props.siteLanguages} communityLanguages={this.props.communityLanguages} - onEdit={this.handleEditCommunity} + onUpsertCommunity={this.props.onEditCommunity} onCancel={this.handleEditCancel} enableNsfw={this.props.enableNsfw} /> @@ -138,18 +178,28 @@ export class Sidebar extends Component { {subscribed === "Subscribed" && ( )} {subscribed === "Pending" && ( )} {community.removed && ( @@ -306,9 +356,13 @@ export class Sidebar extends Component { {community_view.subscribed == "NotSubscribed" && ( )}
@@ -325,16 +379,24 @@ export class Sidebar extends Component { (blocked ? ( ) : ( ))} @@ -388,7 +450,7 @@ export class Sidebar extends Component {
  • @@ -410,7 +472,7 @@ export class Sidebar extends Component {
  • )} @@ -445,9 +511,13 @@ export class Sidebar extends Component { ) : ( )} )} {this.state.showPurgeDialog && ( -
    +
    @@ -506,7 +580,7 @@ export class Sidebar extends Component { />
    - {this.state.purgeLoading ? ( + {this.state.purgeCommunityLoading ? ( ) : (