feat: add post button to relayInfo component
This commit is contained in:
@@ -27,11 +27,13 @@ import Uploader from './Uploader'
|
|||||||
export default function PostContent({
|
export default function PostContent({
|
||||||
defaultContent = '',
|
defaultContent = '',
|
||||||
parentEvent,
|
parentEvent,
|
||||||
close
|
close,
|
||||||
|
openFrom
|
||||||
}: {
|
}: {
|
||||||
defaultContent?: string
|
defaultContent?: string
|
||||||
parentEvent?: Event
|
parentEvent?: Event
|
||||||
close: () => void
|
close: () => void
|
||||||
|
openFrom?: string[]
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { pubkey, publish, checkLogin } = useNostr()
|
const { pubkey, publish, checkLogin } = useNostr()
|
||||||
@@ -233,6 +235,7 @@ export default function PostContent({
|
|||||||
parentEvent={parentEvent}
|
parentEvent={parentEvent}
|
||||||
specifiedRelayUrls={specifiedRelayUrls}
|
specifiedRelayUrls={specifiedRelayUrls}
|
||||||
setSpecifiedRelayUrls={setSpecifiedRelayUrls}
|
setSpecifiedRelayUrls={setSpecifiedRelayUrls}
|
||||||
|
openFrom={openFrom}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
|
|||||||
@@ -13,17 +13,24 @@ import { useTranslation } from 'react-i18next'
|
|||||||
export default function SendOnlyToSwitch({
|
export default function SendOnlyToSwitch({
|
||||||
parentEvent,
|
parentEvent,
|
||||||
specifiedRelayUrls,
|
specifiedRelayUrls,
|
||||||
setSpecifiedRelayUrls
|
setSpecifiedRelayUrls,
|
||||||
|
openFrom
|
||||||
}: {
|
}: {
|
||||||
parentEvent?: Event
|
parentEvent?: Event
|
||||||
specifiedRelayUrls?: string[]
|
specifiedRelayUrls?: string[]
|
||||||
setSpecifiedRelayUrls: Dispatch<SetStateAction<string[] | undefined>>
|
setSpecifiedRelayUrls: Dispatch<SetStateAction<string[] | undefined>>
|
||||||
|
openFrom?: string[]
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { currentRelayUrls } = useCurrentRelays()
|
const { currentRelayUrls } = useCurrentRelays()
|
||||||
const [urls, setUrls] = useState<string[]>([])
|
const [urls, setUrls] = useState<string[]>([])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (openFrom?.length) {
|
||||||
|
setUrls(openFrom)
|
||||||
|
setSpecifiedRelayUrls(openFrom)
|
||||||
|
return
|
||||||
|
}
|
||||||
if (!parentEvent) {
|
if (!parentEvent) {
|
||||||
setUrls(currentRelayUrls)
|
setUrls(currentRelayUrls)
|
||||||
return
|
return
|
||||||
@@ -36,7 +43,7 @@ export default function SendOnlyToSwitch({
|
|||||||
} else {
|
} else {
|
||||||
setUrls(currentRelayUrls)
|
setUrls(currentRelayUrls)
|
||||||
}
|
}
|
||||||
}, [parentEvent, currentRelayUrls])
|
}, [parentEvent, currentRelayUrls, openFrom])
|
||||||
|
|
||||||
if (!urls.length) return null
|
if (!urls.length) return null
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,14 @@ export default function PostEditor({
|
|||||||
defaultContent = '',
|
defaultContent = '',
|
||||||
parentEvent,
|
parentEvent,
|
||||||
open,
|
open,
|
||||||
setOpen
|
setOpen,
|
||||||
|
openFrom
|
||||||
}: {
|
}: {
|
||||||
defaultContent?: string
|
defaultContent?: string
|
||||||
parentEvent?: Event
|
parentEvent?: Event
|
||||||
open: boolean
|
open: boolean
|
||||||
setOpen: Dispatch<boolean>
|
setOpen: Dispatch<boolean>
|
||||||
|
openFrom?: string[]
|
||||||
}) {
|
}) {
|
||||||
const { isSmallScreen } = useScreenSize()
|
const { isSmallScreen } = useScreenSize()
|
||||||
|
|
||||||
@@ -39,6 +41,7 @@ export default function PostEditor({
|
|||||||
defaultContent={defaultContent}
|
defaultContent={defaultContent}
|
||||||
parentEvent={parentEvent}
|
parentEvent={parentEvent}
|
||||||
close={() => setOpen(false)}
|
close={() => setOpen(false)}
|
||||||
|
openFrom={openFrom}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}, [])
|
}, [])
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import { Badge } from '@/components/ui/badge'
|
import { Badge } from '@/components/ui/badge'
|
||||||
|
import { Button } from '@/components/ui/button'
|
||||||
import { useFetchRelayInfo } from '@/hooks'
|
import { useFetchRelayInfo } from '@/hooks'
|
||||||
import { normalizeHttpUrl } from '@/lib/url'
|
import { normalizeHttpUrl } from '@/lib/url'
|
||||||
import { GitBranch, Mail, SquareCode } from 'lucide-react'
|
import { GitBranch, Mail, SquareCode } from 'lucide-react'
|
||||||
|
import { useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import PostEditor from '../PostEditor'
|
||||||
import RelayBadges from '../RelayBadges'
|
import RelayBadges from '../RelayBadges'
|
||||||
import RelayIcon from '../RelayIcon'
|
import RelayIcon from '../RelayIcon'
|
||||||
import UserAvatar from '../UserAvatar'
|
import UserAvatar from '../UserAvatar'
|
||||||
@@ -11,6 +14,8 @@ import Username from '../Username'
|
|||||||
export default function RelayInfo({ url }: { url: string }) {
|
export default function RelayInfo({ url }: { url: string }) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { relayInfo, isFetching } = useFetchRelayInfo(url)
|
const { relayInfo, isFetching } = useFetchRelayInfo(url)
|
||||||
|
const [open, setOpen] = useState(false)
|
||||||
|
|
||||||
if (isFetching || !relayInfo) {
|
if (isFetching || !relayInfo) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -38,29 +43,7 @@ export default function RelayInfo({ url }: { url: string }) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{!!relayInfo.supported_nips?.length && (
|
|
||||||
<div className="space-y-2">
|
|
||||||
<div className="text-sm font-semibold text-muted-foreground">{t('Supported NIPs')}</div>
|
|
||||||
<div className="flex flex-wrap gap-2">
|
|
||||||
{relayInfo.supported_nips
|
|
||||||
.sort((a, b) => a - b)
|
|
||||||
.map((nip) => (
|
|
||||||
<Badge
|
|
||||||
key={nip}
|
|
||||||
variant="secondary"
|
|
||||||
className="clickable"
|
|
||||||
onClick={() =>
|
|
||||||
window.open(
|
|
||||||
`https://github.com/nostr-protocol/nips/blob/master/${formatNip(nip)}.md`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{formatNip(nip)}
|
|
||||||
</Badge>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{relayInfo.payments_url && (
|
{relayInfo.payments_url && (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<div className="text-sm font-semibold text-muted-foreground">{t('Payment page')}:</div>
|
<div className="text-sm font-semibold text-muted-foreground">{t('Payment page')}:</div>
|
||||||
@@ -111,6 +94,10 @@ export default function RelayInfo({ url }: { url: string }) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
<Button variant="secondary" className="w-full" onClick={() => setOpen(true)}>
|
||||||
|
{t('Share something on this Relay')}
|
||||||
|
</Button>
|
||||||
|
<PostEditor open={open} setOpen={setOpen} openFrom={[relayInfo.url]} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -119,10 +106,3 @@ function formatSoftware(software: string) {
|
|||||||
const parts = software.split('/')
|
const parts = software.split('/')
|
||||||
return parts[parts.length - 1]
|
return parts[parts.length - 1]
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatNip(nip: number) {
|
|
||||||
if (nip < 10) {
|
|
||||||
return `0${nip}`
|
|
||||||
}
|
|
||||||
return `${nip}`
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -365,6 +365,7 @@ export default {
|
|||||||
'Clear All': 'مسح الكل',
|
'Clear All': 'مسح الكل',
|
||||||
'Remember my choice': 'تذكر اختياري',
|
'Remember my choice': 'تذكر اختياري',
|
||||||
Apply: 'تطبيق',
|
Apply: 'تطبيق',
|
||||||
Reset: 'إعادة تعيين'
|
Reset: 'إعادة تعيين',
|
||||||
|
'Share something on this Relay': 'شارك شيئاً على هذا الريلاي'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -372,6 +372,7 @@ export default {
|
|||||||
'Clear All': 'Alle löschen',
|
'Clear All': 'Alle löschen',
|
||||||
'Remember my choice': 'Meine Auswahl merken',
|
'Remember my choice': 'Meine Auswahl merken',
|
||||||
Apply: 'Anwenden',
|
Apply: 'Anwenden',
|
||||||
Reset: 'Zurücksetzen'
|
Reset: 'Zurücksetzen',
|
||||||
|
'Share something on this Relay': 'Teile etwas auf diesem Relay'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -366,6 +366,7 @@ export default {
|
|||||||
'Clear All': 'Clear All',
|
'Clear All': 'Clear All',
|
||||||
'Remember my choice': 'Remember my choice',
|
'Remember my choice': 'Remember my choice',
|
||||||
Apply: 'Apply',
|
Apply: 'Apply',
|
||||||
Reset: 'Reset'
|
Reset: 'Reset',
|
||||||
|
'Share something on this Relay': 'Share something on this Relay'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -371,6 +371,7 @@ export default {
|
|||||||
'Clear All': 'Limpiar todo',
|
'Clear All': 'Limpiar todo',
|
||||||
'Remember my choice': 'Recordar mi elección',
|
'Remember my choice': 'Recordar mi elección',
|
||||||
Apply: 'Aplicar',
|
Apply: 'Aplicar',
|
||||||
Reset: 'Restablecer'
|
Reset: 'Restablecer',
|
||||||
|
'Share something on this Relay': 'Comparte algo en este relé'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -366,6 +366,7 @@ export default {
|
|||||||
'Clear All': 'پاک کردن همه',
|
'Clear All': 'پاک کردن همه',
|
||||||
'Remember my choice': 'انتخاب من را به خاطر بسپار',
|
'Remember my choice': 'انتخاب من را به خاطر بسپار',
|
||||||
Apply: 'اعمال',
|
Apply: 'اعمال',
|
||||||
Reset: 'بازنشانی'
|
Reset: 'بازنشانی',
|
||||||
|
'Share something on this Relay': 'در این رله چیزی به اشتراک بگذارید'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -371,6 +371,7 @@ export default {
|
|||||||
'Clear All': 'Tout effacer',
|
'Clear All': 'Tout effacer',
|
||||||
'Remember my choice': 'Se souvenir de mon choix',
|
'Remember my choice': 'Se souvenir de mon choix',
|
||||||
Apply: 'Appliquer',
|
Apply: 'Appliquer',
|
||||||
Reset: 'Réinitialiser'
|
Reset: 'Réinitialiser',
|
||||||
|
'Share something on this Relay': 'Partager quelque chose sur ce relais'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -370,6 +370,7 @@ export default {
|
|||||||
'Clear All': 'Cancella tutto',
|
'Clear All': 'Cancella tutto',
|
||||||
'Remember my choice': 'Ricorda la mia scelta',
|
'Remember my choice': 'Ricorda la mia scelta',
|
||||||
Apply: 'Applica',
|
Apply: 'Applica',
|
||||||
Reset: 'Reimposta'
|
Reset: 'Reimposta',
|
||||||
|
'Share something on this Relay': 'Condividi qualcosa su questo Relay'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -368,6 +368,7 @@ export default {
|
|||||||
'Clear All': 'すべてクリア',
|
'Clear All': 'すべてクリア',
|
||||||
'Remember my choice': '選択を記憶',
|
'Remember my choice': '選択を記憶',
|
||||||
Apply: '適用',
|
Apply: '適用',
|
||||||
Reset: 'リセット'
|
Reset: 'リセット',
|
||||||
|
'Share something on this Relay': 'このリレーで何かを共有する'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -367,6 +367,7 @@ export default {
|
|||||||
'Clear All': '모두 지우기',
|
'Clear All': '모두 지우기',
|
||||||
'Remember my choice': '내 선택 기억하기',
|
'Remember my choice': '내 선택 기억하기',
|
||||||
Apply: '적용',
|
Apply: '적용',
|
||||||
Reset: '초기화'
|
Reset: '초기화',
|
||||||
|
'Share something on this Relay': '이 릴레이에서 무언가를 공유하세요'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -370,6 +370,7 @@ export default {
|
|||||||
'Clear All': 'Wyczyść wszystko',
|
'Clear All': 'Wyczyść wszystko',
|
||||||
'Remember my choice': 'Zapamiętaj mój wybór',
|
'Remember my choice': 'Zapamiętaj mój wybór',
|
||||||
Apply: 'Zastosuj',
|
Apply: 'Zastosuj',
|
||||||
Reset: 'Resetuj'
|
Reset: 'Resetuj',
|
||||||
|
'Share something on this Relay': 'Udostępnij coś na tym przekaźniku'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -369,6 +369,7 @@ export default {
|
|||||||
'Clear All': 'Limpar tudo',
|
'Clear All': 'Limpar tudo',
|
||||||
'Remember my choice': 'Lembrar minha escolha',
|
'Remember my choice': 'Lembrar minha escolha',
|
||||||
Apply: 'Aplicar',
|
Apply: 'Aplicar',
|
||||||
Reset: 'Redefinir'
|
Reset: 'Redefinir',
|
||||||
|
'Share something on this Relay': 'Compartilhe algo neste Relay'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -370,6 +370,7 @@ export default {
|
|||||||
'Clear All': 'Limpar tudo',
|
'Clear All': 'Limpar tudo',
|
||||||
'Remember my choice': 'Lembrar a minha escolha',
|
'Remember my choice': 'Lembrar a minha escolha',
|
||||||
Apply: 'Aplicar',
|
Apply: 'Aplicar',
|
||||||
Reset: 'Repor'
|
Reset: 'Repor',
|
||||||
|
'Share something on this Relay': 'Partilhe algo neste Relay'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -370,6 +370,7 @@ export default {
|
|||||||
'Clear All': 'Очистить все',
|
'Clear All': 'Очистить все',
|
||||||
'Remember my choice': 'Запомнить мой выбор',
|
'Remember my choice': 'Запомнить мой выбор',
|
||||||
Apply: 'Применить',
|
Apply: 'Применить',
|
||||||
Reset: 'Сбросить'
|
Reset: 'Сбросить',
|
||||||
|
'Share something on this Relay': 'Поделиться чем-то на этом релее'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -364,6 +364,7 @@ export default {
|
|||||||
'Clear All': 'ล้างทั้งหมด',
|
'Clear All': 'ล้างทั้งหมด',
|
||||||
'Remember my choice': 'จำการเลือกของฉัน',
|
'Remember my choice': 'จำการเลือกของฉัน',
|
||||||
Apply: 'ใช้',
|
Apply: 'ใช้',
|
||||||
Reset: 'รีเซ็ต'
|
Reset: 'รีเซ็ต',
|
||||||
|
'Share something on this Relay': 'แชร์บางอย่างบนรีเลย์นี้'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -362,6 +362,7 @@ export default {
|
|||||||
'Clear All': '清空',
|
'Clear All': '清空',
|
||||||
'Remember my choice': '记住我的选择',
|
'Remember my choice': '记住我的选择',
|
||||||
Apply: '应用',
|
Apply: '应用',
|
||||||
Reset: '重置'
|
Reset: '重置',
|
||||||
|
'Share something on this Relay': '在此服务器上分享点什么'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user