Show parent comment for comment link. Fixes #1030 (#1032)

* Show parent comment for comment link. Fixes #1030

* Changing let to const.
This commit is contained in:
Dessalines 2023-05-21 21:30:13 -04:00 committed by GitHub
parent 0bd9a17009
commit 26de38a869
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -42,6 +42,7 @@ import {
colorList, colorList,
commentTreeMaxDepth, commentTreeMaxDepth,
futureDaysToUnixTime, futureDaysToUnixTime,
getCommentParentId,
isAdmin, isAdmin,
isBanned, isBanned,
isMod, isMod,
@ -1051,11 +1052,14 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
? i18n.t("show_context") ? i18n.t("show_context")
: i18n.t("link"); : i18n.t("link");
// The context button should show the parent comment by default
const parentCommentId = getCommentParentId(cv.comment) ?? cv.comment.id;
return ( return (
<> <>
<Link <Link
className={classnames} className={classnames}
to={`/comment/${cv.comment.id}`} to={`/comment/${parentCommentId}`}
title={title} title={title}
> >
<Icon icon="link" classes="icon-inline" /> <Icon icon="link" classes="icon-inline" />