feat: add option to copy share link (#349)
This commit is contained in:
committed by
GitHub
parent
6ee9cc1fd2
commit
0136515540
@@ -7,12 +7,12 @@ import {
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from '@/components/ui/dropdown-menu'
|
||||
import { getSharableEventId } from '@/lib/event'
|
||||
import { getSharableEventId, getSharableEventLink } from '@/lib/event'
|
||||
import { pubkeyToNpub } from '@/lib/pubkey'
|
||||
import { useMuteList } from '@/providers/MuteListProvider'
|
||||
import { useNostr } from '@/providers/NostrProvider'
|
||||
import { useScreenSize } from '@/providers/ScreenSizeProvider'
|
||||
import { Bell, BellOff, Code, Copy, Ellipsis } from 'lucide-react'
|
||||
import { Bell, BellOff, Code, Copy, Ellipsis, Link } from 'lucide-react'
|
||||
import { Event } from 'nostr-tools'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
@@ -74,6 +74,17 @@ export default function NoteOptions({ event, className }: { event: Event; classN
|
||||
<Copy />
|
||||
{t('Copy user ID')}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setIsDrawerOpen(false)
|
||||
navigator.clipboard.writeText(getSharableEventLink(event))
|
||||
}}
|
||||
className="w-full p-6 justify-start text-lg gap-4 [&_svg]:size-5"
|
||||
variant="ghost"
|
||||
>
|
||||
<Link />
|
||||
{t('Copy share link')}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setIsRawEventDialogOpen(true)
|
||||
@@ -126,7 +137,15 @@ export default function NoteOptions({ event, className }: { event: Event; classN
|
||||
<Copy />
|
||||
{t('Copy user ID')}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() => navigator.clipboard.writeText(getSharableEventLink(event))}
|
||||
>
|
||||
<Link />
|
||||
{t('Copy share link')}
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem onClick={() => setIsRawEventDialogOpen(true)}>
|
||||
<Code />
|
||||
{t('View raw event')}
|
||||
|
||||
@@ -43,6 +43,7 @@ export default {
|
||||
Quote: 'Citar',
|
||||
'Copy event ID': 'Copiar ID do evento',
|
||||
'Copy user ID': 'Copiar ID do usuário',
|
||||
'Copy share ink': 'Copiar link de compartilhamento',
|
||||
'View raw event': 'Ver evento bruto',
|
||||
Like: 'Curtir',
|
||||
'switch to light theme': 'Alternar para tema claro',
|
||||
|
||||
@@ -129,6 +129,10 @@ export function getSharableEventId(event: Event) {
|
||||
return nip19.neventEncode({ id: event.id, author: event.pubkey, kind: event.kind, relays: hints })
|
||||
}
|
||||
|
||||
export function getSharableEventLink(event: Event) {
|
||||
return `https://njump.me/${getSharableEventId(event)}`
|
||||
}
|
||||
|
||||
export function getUsingClient(event: Event) {
|
||||
return event.tags.find(tagNameEquals('client'))?.[1]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user