From a447e432db8a185f1df998f91d35891eb185af4e Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Sun, 21 May 2023 18:13:25 +0000 Subject: [PATCH 1/2] Show language on posts and comments (#1026) * Show language on posts and comments * Revert "Show language on posts and comments" This reverts commit 54267903fc6941762030ec20daa048d47662d50d. * Change language indicator look --- src/shared/components/comment/comment-node.tsx | 9 ++++++++- src/shared/components/post/post-listing.tsx | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/shared/components/comment/comment-node.tsx b/src/shared/components/comment/comment-node.tsx index d68c5b30..16e0a731 100644 --- a/src/shared/components/comment/comment-node.tsx +++ b/src/shared/components/comment/comment-node.tsx @@ -282,8 +282,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() && ( <> { )} + + { + this.props.allLanguages.find( + lang => lang.id === post_view.post.language_id + )?.name + } +
  • {url && !(hostname(url) === getExternalHost()) && ( <> From 0bd9a170098e1b328a6e5c15c98a06b67ad99b39 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Sun, 21 May 2023 18:17:56 +0000 Subject: [PATCH 2/2] Add web share for browsers that have it enabled (#1029) Co-authored-by: Dessalines --- src/assets/symbols.svg | 7 +++++++ src/shared/components/post/post-listing.tsx | 23 ++++++++++++++++++++- src/shared/utils.ts | 10 +++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) 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/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index cfaa81ee..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"; @@ -567,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 b5b39c4f..2e18e2b8 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -1593,3 +1593,13 @@ export function isAuthPath(pathname: string) { pathname ); } + +export function canShare() { + return isBrowser() && !!navigator.canShare; +} + +export function share(shareData: ShareData) { + if (isBrowser()) { + navigator.share(shareData); + } +}