From 9f5f81431b7b1ae5a3956d6e68c691b1d4fb7ca0 Mon Sep 17 00:00:00 2001 From: Dogeek Date: Sat, 24 Jun 2023 13:51:10 +0200 Subject: [PATCH] also open external links when setting is enabled --- src/shared/components/post/post-listing.tsx | 29 ++++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index 19b44a31..507fb3d1 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -332,6 +332,7 @@ export class PostListing extends Component { href={url} rel={relTags} title={url} + target={this.linkTarget} > {this.imgThumb(this.imageSrc)} @@ -348,6 +349,7 @@ export class PostListing extends Component { data-tippy-content={I18NextService.i18n.t("expand_here")} onClick={linkEvent(this, this.handleImageExpandClick)} aria-label={I18NextService.i18n.t("expand_here")} + target={this.linkTarget} >
@@ -356,7 +358,13 @@ export class PostListing extends Component { ); } else { return ( - +
@@ -369,6 +377,7 @@ export class PostListing extends Component { className="text-body" to={`/post/${post.id}`} title={I18NextService.i18n.t("comments")} + target={this.linkTarget} >
@@ -746,6 +755,17 @@ export class PostListing extends Component { ); } + public get linkTarget(): string { + if ( + UserService.Instance.myUserInfo?.local_user_view.local_user + .open_links_in_new_tab + ) { + return "_blank"; + } + // _self is the default target on links when the field is not specified + return "_self"; + } + get commentsButton() { const post_view = this.postView; const title = I18NextService.i18n.t("number_of_comments", { @@ -759,12 +779,7 @@ export class PostListing extends Component { title={title} to={`/post/${post_view.post.id}?scrollToComments=true`} data-tippy-content={title} - target={ - UserService.Instance.myUserInfo?.local_user_view.local_user - .open_links_in_new_tab - ? "_blank" - : "_self" - } + target={this.linkTarget} > {post_view.counts.comments}