]> Untitled Git - lemmy-ui.git/commitdiff
Fix non-local community and person links. Fixes #290
authorDessalines <tyhou13@gmx.com>
Wed, 5 May 2021 14:57:41 +0000 (10:57 -0400)
committerDessalines <tyhou13@gmx.com>
Wed, 5 May 2021 14:57:41 +0000 (10:57 -0400)
src/shared/components/community-link.tsx
src/shared/components/person-listing.tsx

index 5a85a127e80d4365d8629e4225c9b54936ceac3c..c12f570b7ec187cbcb1c938436e0b189ebbebe4c 100644 (file)
@@ -36,17 +36,34 @@ export class CommunityLink extends Component<CommunityLinkProps, any> {
 
     let apubName = `!${name_}`;
     let displayName = this.props.useApubName ? apubName : title;
-    return (
+    return !this.props.realLink ? (
       <Link
         title={apubName}
         className={`${this.props.muted ? "text-muted" : ""}`}
         to={link}
       >
+        {this.avatarAndName(displayName)}
+      </Link>
+    ) : (
+      <a
+        title={apubName}
+        className={`${this.props.muted ? "text-muted" : ""}`}
+        href={link}
+      >
+        {this.avatarAndName(displayName)}
+      </a>
+    );
+  }
+
+  avatarAndName(displayName: string) {
+    let community = this.props.community;
+    return (
+      <>
         {!this.props.hideAvatar && community.icon && showAvatars() && (
           <PictrsImage src={community.icon} icon />
         )}
         <span>{displayName}</span>
-      </Link>
+      </>
     );
   }
 }
index fda388df587d77e94120243d5c16b42965ae1069..17265760d5880710a383f4aa8204e8b8f112647d 100644 (file)
@@ -44,19 +44,38 @@ export class PersonListing extends Component<PersonListingProps, any> {
 
     return (
       <>
-        <Link
-          title={apubName}
-          className={this.props.muted ? "text-muted" : "text-info"}
-          to={link}
-        >
-          {!this.props.hideAvatar && person.avatar && showAvatars() && (
-            <PictrsImage src={person.avatar} icon />
-          )}
-          <span>{displayName}</span>
-        </Link>
+        {!this.props.realLink ? (
+          <Link
+            title={apubName}
+            className={this.props.muted ? "text-muted" : "text-info"}
+            to={link}
+          >
+            {this.avatarAndName(displayName)}
+          </Link>
+        ) : (
+          <a
+            title={apubName}
+            className={this.props.muted ? "text-muted" : "text-info"}
+            href={link}
+          >
+            {this.avatarAndName(displayName)}
+          </a>
+        )}
 
         {isCakeDay(person.published) && <CakeDay creatorName={apubName} />}
       </>
     );
   }
+
+  avatarAndName(displayName: string) {
+    let person = this.props.person;
+    return (
+      <>
+        {!this.props.hideAvatar && person.avatar && showAvatars() && (
+          <PictrsImage src={person.avatar} icon />
+        )}
+        <span>{displayName}</span>
+      </>
+    );
+  }
 }