]> Untitled Git - lemmy-ui.git/blobdiff - src/shared/components/community/community.tsx
Adding Community Language fixes. #783 (#868)
[lemmy-ui.git] / src / shared / components / community / community.tsx
index 77c01d62ad053559b6680390a91bde914388c86a..7ce6099988d9c9a866a3906532ea4e0fac3d88ba 100644 (file)
@@ -278,6 +278,16 @@ export class Community extends Component<any, State> {
   }
 
   render() {
+    // For some reason, this returns an empty vec if it matches the site langs
+    let communityLangs = this.state.communityRes.map(r => {
+      let langs = r.discussion_languages;
+      if (langs.length == 0) {
+        return this.state.siteRes.all_languages.map(l => l.id);
+      } else {
+        return langs;
+      }
+    });
+
     return (
       <div className="container-lg">
         {this.state.communityLoading ? (
@@ -321,6 +331,12 @@ export class Community extends Component<any, State> {
                             admins={this.state.siteRes.admins}
                             online={res.online}
                             enableNsfw={enableNsfw(this.state.siteRes)}
+                            editable
+                            allLanguages={this.state.siteRes.all_languages}
+                            siteLanguages={
+                              this.state.siteRes.discussion_languages
+                            }
+                            communityLanguages={communityLangs}
                           />
                           {!res.community_view.community.local &&
                             res.site.match({
@@ -352,6 +368,10 @@ export class Community extends Component<any, State> {
                       admins={this.state.siteRes.admins}
                       online={res.online}
                       enableNsfw={enableNsfw(this.state.siteRes)}
+                      editable
+                      allLanguages={this.state.siteRes.all_languages}
+                      siteLanguages={this.state.siteRes.discussion_languages}
+                      communityLanguages={communityLangs}
                     />
                     {!res.community_view.community.local &&
                       res.site.match({
@@ -390,6 +410,7 @@ export class Community extends Component<any, State> {
           enableDownvotes={enableDownvotes(this.state.siteRes)}
           enableNsfw={enableNsfw(this.state.siteRes)}
           allLanguages={this.state.siteRes.all_languages}
+          siteLanguages={this.state.siteRes.discussion_languages}
         />
       )
     ) : this.state.commentsLoading ? (
@@ -407,6 +428,7 @@ export class Community extends Component<any, State> {
         admins={Some(this.state.siteRes.admins)}
         maxCommentsShown={None}
         allLanguages={this.state.siteRes.all_languages}
+        siteLanguages={this.state.siteRes.discussion_languages}
       />
     );
   }
@@ -559,7 +581,10 @@ export class Community extends Component<any, State> {
     ) {
       let data = wsJsonToRes<CommunityResponse>(msg, CommunityResponse);
       this.state.communityRes.match({
-        some: res => (res.community_view = data.community_view),
+        some: res => {
+          res.community_view = data.community_view;
+          res.discussion_languages = data.discussion_languages;
+        },
         none: void 0,
       });
       this.setState(this.state);