feat: add global and local share

This commit is contained in:
Xylight committed 2024-06-12 14:00:41 -07:00
1 parent 3e2ccbd220
commit c98845d342
3 files changed
+34 -5

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@
last:rounded-r-lg last:border-r last:dark:border-r-transparent last:rounded-r-lg last:border-r last:dark:border-r-transparent
rounded-l-none rounded-l-none
rounded-r-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 !selected
? `hover:dark:bg-zinc-800 border-slate-100 border-t border-b border-b-slate-300 dark:border-b-0 ? `hover:dark:bg-zinc-800 border-slate-100 border-t border-b border-b-slate-300 dark:border-b-0
@@ -13,6 +13,8 @@
Eye, Eye,
EyeSlash, EyeSlash,
Flag, Flag,
GlobeAlt,
Home,
Icon, Icon,
Language, Language,
Newspaper, Newspaper,
@@ -48,14 +50,17 @@
MenuDivider, MenuDivider,
Modal, Modal,
Spinner, Spinner,
toast,
} from 'mono-svelte' } from 'mono-svelte'
import { fediseer, type Data } from '$lib/fediseer/fediseer' import { fediseer, type Data } from '$lib/fediseer/fediseer'
import Fediseer from '$lib/fediseer/Fediseer.svelte' import Fediseer from '$lib/fediseer/Fediseer.svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import { text } from '$lib/components/translate/translation' import { text } from '$lib/components/translate/translation'
import Translation from '$lib/components/translate/Translation.svelte' import Translation from '$lib/components/translate/Translation.svelte'
import { hidePost } from './helpers' import { hidePost, postLink } from './helpers'
import { feature } from '$lib/version' import { feature } from '$lib/version'
import Switch from '$lib/components/input/Switch.svelte'
import { instanceToURL } from '$lib/util'
export let post: PostView export let post: PostView
@@ -70,6 +75,8 @@
let fediseerLoading = false let fediseerLoading = false
let translating = false let translating = false
let localShare = false
</script> </script>
{#if fediseerData} {#if fediseerData}
@@ -252,12 +259,33 @@
<MenuButton <MenuButton
on:click={() => { on:click={() => {
navigator.share?.({ navigator.share?.({
url: post.post.ap_id, url: localShare
}) ?? navigator.clipboard.writeText(post.post.ap_id) ? `${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"
> >
<Icon src={Share} width={16} mini slot="prefix" /> <Icon src={Share} width={16} mini slot="prefix" />
{$t('post.actions.more.share')} {$t('post.actions.more.share')}
{#if !post.post.local}
<Switch
optionNames={[
$t('filter.location.global'),
$t('filter.location.local'),
]}
options={[false, true]}
bind:selected={localShare}
class="ml-auto"
buttonClass="!py-1"
/>
{/if}
</MenuButton> </MenuButton>
{#if post.post.body && $userSettings.translator} {#if post.post.body && $userSettings.translator}
<MenuButton <MenuButton
+2 -1
View File
@@ -53,7 +53,8 @@
"all": "All", "all": "All",
"local": "Local", "local": "Local",
"subscribed": "Subscribed", "subscribed": "Subscribed",
"moderator": "Moderator" "moderator": "Moderator",
"global": "Global"
}, },
"sort": { "sort": {
"label": "Sort", "label": "Sort",