]> Untitled Git - lemmy-ui.git/blobdiff - src/shared/components/person/profile.tsx
Adding Community Language fixes. #783 (#868)
[lemmy-ui.git] / src / shared / components / person / profile.tsx
index b93872847ca319f220757ec05fc0117ce6a76991..47399843cab521e119195d8f15d02d9e1a2a8ad0 100644 (file)
@@ -129,8 +129,6 @@ export class Profile extends Component<any, ProfileState> {
     } else {
       this.fetchUserData();
     }
-
-    this.setPersonBlock();
   }
 
   fetchUserData() {
@@ -209,6 +207,7 @@ export class Profile extends Component<any, ProfileState> {
   }
 
   componentDidMount() {
+    this.setPersonBlock();
     setupTippy();
   }
 
@@ -239,20 +238,16 @@ export class Profile extends Component<any, ProfileState> {
   }
 
   get documentTitle(): string {
-    return this.state.siteRes.site_view.match({
-      some: siteView =>
-        this.state.personRes.match({
-          some: res =>
-            `@${res.person_view.person.name} - ${siteView.site.name}`,
-          none: "",
-        }),
+    return this.state.personRes.match({
+      some: res =>
+        `@${res.person_view.person.name} - ${this.state.siteRes.site_view.site.name}`,
       none: "",
     });
   }
 
   render() {
     return (
-      <div className="container">
+      <div className="container-lg">
         {this.state.loading ? (
           <h5>
             <Spinner large />
@@ -284,6 +279,7 @@ export class Profile extends Component<any, ProfileState> {
                     view={this.state.view}
                     onPageChange={this.handlePageChange}
                     allLanguages={this.state.siteRes.all_languages}
+                    siteLanguages={this.state.siteRes.discussion_languages}
                   />
                 </div>
 
@@ -413,9 +409,12 @@ export class Profile extends Component<any, ProfileState> {
               <div className="">
                 <div className="mb-0 d-flex flex-wrap">
                   <div>
-                    {pv.person.display_name && (
-                      <h5 className="mb-0">{pv.person.display_name}</h5>
-                    )}
+                    {pv.person.display_name.match({
+                      some: displayName => (
+                        <h5 className="mb-0">{displayName}</h5>
+                      ),
+                      none: <></>,
+                    })}
                     <ul className="list-inline mb-2">
                       <li className="list-inline-item">
                         <PersonListing
@@ -431,6 +430,11 @@ export class Profile extends Component<any, ProfileState> {
                           {i18n.t("banned")}
                         </li>
                       )}
+                      {pv.person.deleted && (
+                        <li className="list-inline-item badge badge-danger">
+                          {i18n.t("deleted")}
+                        </li>
+                      )}
                       {pv.person.admin && (
                         <li className="list-inline-item badge badge-light">
                           {i18n.t("admin")}
@@ -662,25 +666,28 @@ export class Profile extends Component<any, ProfileState> {
       });
   }
 
-  // TODO test this, make sure its good
   moderates() {
     return this.state.personRes
       .map(r => r.moderates)
       .match({
         some: moderates => {
           if (moderates.length > 0) {
-            <div className="card border-secondary mb-3">
-              <div className="card-body">
-                <h5>{i18n.t("moderates")}</h5>
-                <ul className="list-unstyled mb-0">
-                  {moderates.map(cmv => (
-                    <li key={cmv.community.id}>
-                      <CommunityLink community={cmv.community} />
-                    </li>
-                  ))}
-                </ul>
+            return (
+              <div className="card border-secondary mb-3">
+                <div className="card-body">
+                  <h5>{i18n.t("moderates")}</h5>
+                  <ul className="list-unstyled mb-0">
+                    {moderates.map(cmv => (
+                      <li key={cmv.community.id}>
+                        <CommunityLink community={cmv.community} />
+                      </li>
+                    ))}
+                  </ul>
+                </div>
               </div>
-            </div>;
+            );
+          } else {
+            return <></>;
           }
         },
         none: void 0,
@@ -693,18 +700,22 @@ export class Profile extends Component<any, ProfileState> {
       .match({
         some: follows => {
           if (follows.length > 0) {
-            <div className="card border-secondary mb-3">
-              <div className="card-body">
-                <h5>{i18n.t("subscribed")}</h5>
-                <ul className="list-unstyled mb-0">
-                  {follows.map(cfv => (
-                    <li key={cfv.community.id}>
-                      <CommunityLink community={cfv.community} />
-                    </li>
-                  ))}
-                </ul>
+            return (
+              <div className="card border-secondary mb-3">
+                <div className="card-body">
+                  <h5>{i18n.t("subscribed")}</h5>
+                  <ul className="list-unstyled mb-0">
+                    {follows.map(cfv => (
+                      <li key={cfv.community.id}>
+                        <CommunityLink community={cfv.community} />
+                      </li>
+                    ))}
+                  </ul>
+                </div>
               </div>
-            </div>;
+            );
+          } else {
+            return <></>;
           }
         },
         none: void 0,
@@ -854,7 +865,7 @@ export class Profile extends Component<any, ProfileState> {
       op == UserOperation.DeletePost ||
       op == UserOperation.RemovePost ||
       op == UserOperation.LockPost ||
-      op == UserOperation.StickyPost ||
+      op == UserOperation.FeaturePost ||
       op == UserOperation.SavePost
     ) {
       let data = wsJsonToRes<PostResponse>(msg, PostResponse);