diff --git a/src/assets/symbols.svg b/src/assets/symbols.svg index 2fb8eac7..72214eaf 100644 --- a/src/assets/symbols.svg +++ b/src/assets/symbols.svg @@ -251,5 +251,12 @@ + + + + + + + diff --git a/src/shared/components/comment/comment-node.tsx b/src/shared/components/comment/comment-node.tsx index d68c5b30..d2dee1e8 100644 --- a/src/shared/components/comment/comment-node.tsx +++ b/src/shared/components/comment/comment-node.tsx @@ -42,6 +42,7 @@ import { colorList, commentTreeMaxDepth, futureDaysToUnixTime, + getCommentParentId, isAdmin, isBanned, isMod, @@ -282,8 +283,15 @@ export class CommentNode extends Component { )} {this.linkBtn(true)} + + { + this.props.allLanguages.find( + lang => lang.id === cv.comment.language_id + )?.name + } + {/* This is an expanding spacer for mobile */} -
+
{showScores() && ( <> { ? i18n.t("show_context") : i18n.t("link"); + // The context button should show the parent comment by default + const parentCommentId = getCommentParentId(cv.comment) ?? cv.comment.id; + return ( <> diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index 1096b73e..fd9b883e 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -22,7 +22,7 @@ import { SavePost, TransferCommunity, } from "lemmy-js-client"; -import { getExternalHost } from "../../env"; +import { getExternalHost, getHttpBase } from "../../env"; import { i18n } from "../../i18next"; import { BanType, PostFormParams, PurgeType } from "../../interfaces"; import { UserService, WebSocketService } from "../../services"; @@ -32,6 +32,7 @@ import { amMod, canAdmin, canMod, + canShare, futureDaysToUnixTime, hostname, isAdmin, @@ -46,6 +47,7 @@ import { numToSI, relTags, setupTippy, + share, showScores, wsClient, } from "../../utils"; @@ -342,6 +344,13 @@ export class PostListing extends Component { )} + + { + this.props.allLanguages.find( + lang => lang.id === post_view.post.language_id + )?.name + } +
  • {url && !(hostname(url) === getExternalHost()) && ( <> @@ -560,9 +569,19 @@ export class PostListing extends Component { commentsLine(mobile = false) { let post = this.props.post_view.post; + return (
    {this.commentsButton} + {canShare() && ( + + )} {!post.local && ( { this.setState({ showEdit: false }); } + handleShare(i: PostListing) { + const { name, body, id } = i.props.post_view.post; + share({ + title: name, + text: body?.slice(0, 50), + url: `${getHttpBase()}/post/${id}`, + }); + } + handleShowReportDialog(i: PostListing) { i.setState({ showReportDialog: !i.state.showReportDialog }); } diff --git a/src/shared/utils.ts b/src/shared/utils.ts index 33fe7d63..5648df00 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -1591,3 +1591,13 @@ export function isAuthPath(pathname: string) { pathname ); } + +export function canShare() { + return isBrowser() && !!navigator.canShare; +} + +export function share(shareData: ShareData) { + if (isBrowser()) { + navigator.share(shareData); + } +}