1 import { Component } from "inferno";
2 import { CommunityView, GetSiteResponse } from "lemmy-js-client";
3 import { Subscription } from "rxjs";
4 import { i18n } from "../../i18next";
12 import { HtmlTags } from "../common/html-tags";
13 import { Spinner } from "../common/icon";
14 import { CommunityForm } from "./community-form";
16 interface CreateCommunityState {
17 siteRes: GetSiteResponse;
21 export class CreateCommunity extends Component<any, CreateCommunityState> {
22 private isoData = setIsoData(this.context);
23 private subscription?: Subscription;
24 state: CreateCommunityState = {
25 siteRes: this.isoData.site_res,
28 constructor(props: any, context: any) {
29 super(props, context);
30 this.handleCommunityCreate = this.handleCommunityCreate.bind(this);
32 this.parseMessage = this.parseMessage.bind(this);
33 this.subscription = wsSubscribe(this.parseMessage);
36 componentWillUnmount() {
38 this.subscription?.unsubscribe();
42 get documentTitle(): string {
43 return `${i18n.t("create_community")} - ${
44 this.state.siteRes.site_view.site.name
50 <div className="container-lg">
52 title={this.documentTitle}
53 path={this.context.router.route.match.url}
55 {this.state.loading ? (
61 <div className="col-12 col-lg-6 offset-lg-3 mb-4">
62 <h5>{i18n.t("create_community")}</h5>
64 onCreate={this.handleCommunityCreate}
65 enableNsfw={enableNsfw(this.state.siteRes)}
66 allLanguages={this.state.siteRes.all_languages}
67 siteLanguages={this.state.siteRes.discussion_languages}
68 communityLanguages={this.state.siteRes.discussion_languages}
77 handleCommunityCreate(cv: CommunityView) {
78 this.props.history.push(`/c/${cv.community.name}`);
81 parseMessage(msg: any) {
83 toast(i18n.t(msg.error), "danger");