From c98845d342f88d6de6b56230e69b8da140d4948b Mon Sep 17 00:00:00 2001 From: Xylight Date: Wed, 12 Jun 2024 13:53:40 -0700 Subject: [PATCH] feat: add global and local share --- src/lib/components/input/Switch.svelte | 2 +- .../components/lemmy/post/PostActions.svelte | 34 +++++++++++++++++-- src/lib/i18n/en.json | 3 +- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/lib/components/input/Switch.svelte b/src/lib/components/input/Switch.svelte index e9412747..10bca9ce 100644 --- a/src/lib/components/input/Switch.svelte +++ b/src/lib/components/input/Switch.svelte @@ -27,7 +27,7 @@ last:rounded-r-lg last:border-r last:dark:border-r-transparent rounded-l-none rounded-r-none - px-3 py-1.5 text-sm hover:brightness-110 + px-3 py-1.5 text-sm hover:brightness-110 ${$$props.buttonClass || ''} ${ !selected ? `hover:dark:bg-zinc-800 border-slate-100 border-t border-b border-b-slate-300 dark:border-b-0 diff --git a/src/lib/components/lemmy/post/PostActions.svelte b/src/lib/components/lemmy/post/PostActions.svelte index f4c0bf20..42e21f19 100644 --- a/src/lib/components/lemmy/post/PostActions.svelte +++ b/src/lib/components/lemmy/post/PostActions.svelte @@ -13,6 +13,8 @@ Eye, EyeSlash, Flag, + GlobeAlt, + Home, Icon, Language, Newspaper, @@ -48,14 +50,17 @@ MenuDivider, Modal, Spinner, + toast, } from 'mono-svelte' import { fediseer, type Data } from '$lib/fediseer/fediseer' import Fediseer from '$lib/fediseer/Fediseer.svelte' import { t } from '$lib/translations' import { text } from '$lib/components/translate/translation' import Translation from '$lib/components/translate/Translation.svelte' - import { hidePost } from './helpers' + import { hidePost, postLink } from './helpers' import { feature } from '$lib/version' + import Switch from '$lib/components/input/Switch.svelte' + import { instanceToURL } from '$lib/util' export let post: PostView @@ -70,6 +75,8 @@ let fediseerLoading = false let translating = false + + let localShare = false {#if fediseerData} @@ -252,12 +259,33 @@ { navigator.share?.({ - url: post.post.ap_id, - }) ?? navigator.clipboard.writeText(post.post.ap_id) + url: localShare + ? `${instanceToURL(getInstance())}/post/${post.post.id}` + : post.post.ap_id, + }) ?? + navigator.clipboard.writeText( + localShare + ? `${instanceToURL(getInstance())}/post/${post.post.id}` + : post.post.ap_id + ) + toast({ content: $t('toast.copied') }) }} + class="flex-1 py-0" > {$t('post.actions.more.share')} + {#if !post.post.local} + + {/if} {#if post.post.body && $userSettings.translator}