|
|
|
@ -17,6 +17,7 @@ import { |
|
|
|
import { Separator } from '@/components/ui/separator' |
|
|
|
import { Separator } from '@/components/ui/separator' |
|
|
|
import { normalizeUrl } from '@/lib/url' |
|
|
|
import { normalizeUrl } from '@/lib/url' |
|
|
|
import { useFavoriteRelays } from '@/providers/FavoriteRelaysProvider' |
|
|
|
import { useFavoriteRelays } from '@/providers/FavoriteRelaysProvider' |
|
|
|
|
|
|
|
import { useNostr } from '@/providers/NostrProvider' |
|
|
|
import { useScreenSize } from '@/providers/ScreenSizeProvider' |
|
|
|
import { useScreenSize } from '@/providers/ScreenSizeProvider' |
|
|
|
import { TRelaySet } from '@/types' |
|
|
|
import { TRelaySet } from '@/types' |
|
|
|
import { Check, FolderPlus, Plus, Star } from 'lucide-react' |
|
|
|
import { Check, FolderPlus, Plus, Star } from 'lucide-react' |
|
|
|
@ -138,10 +139,15 @@ function RelayItem({ urls }: { urls: string[] }) { |
|
|
|
|
|
|
|
|
|
|
|
function RelaySetItem({ set, urls }: { set: TRelaySet; urls: string[] }) { |
|
|
|
function RelaySetItem({ set, urls }: { set: TRelaySet; urls: string[] }) { |
|
|
|
const { isSmallScreen } = useScreenSize() |
|
|
|
const { isSmallScreen } = useScreenSize() |
|
|
|
|
|
|
|
const { pubkey, startLogin } = useNostr() |
|
|
|
const { updateRelaySet } = useFavoriteRelays() |
|
|
|
const { updateRelaySet } = useFavoriteRelays() |
|
|
|
const saved = urls.every((url) => set.relayUrls.includes(url)) |
|
|
|
const saved = urls.every((url) => set.relayUrls.includes(url)) |
|
|
|
|
|
|
|
|
|
|
|
const handleClick = () => { |
|
|
|
const handleClick = () => { |
|
|
|
|
|
|
|
if (!pubkey) { |
|
|
|
|
|
|
|
startLogin() |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
if (saved) { |
|
|
|
if (saved) { |
|
|
|
updateRelaySet({ |
|
|
|
updateRelaySet({ |
|
|
|
...set, |
|
|
|
...set, |
|
|
|
@ -175,9 +181,14 @@ function RelaySetItem({ set, urls }: { set: TRelaySet; urls: string[] }) { |
|
|
|
function SaveToNewSet({ urls }: { urls: string[] }) { |
|
|
|
function SaveToNewSet({ urls }: { urls: string[] }) { |
|
|
|
const { t } = useTranslation() |
|
|
|
const { t } = useTranslation() |
|
|
|
const { isSmallScreen } = useScreenSize() |
|
|
|
const { isSmallScreen } = useScreenSize() |
|
|
|
|
|
|
|
const { pubkey, startLogin } = useNostr() |
|
|
|
const { createRelaySet } = useFavoriteRelays() |
|
|
|
const { createRelaySet } = useFavoriteRelays() |
|
|
|
|
|
|
|
|
|
|
|
const handleSave = () => { |
|
|
|
const handleSave = () => { |
|
|
|
|
|
|
|
if (!pubkey) { |
|
|
|
|
|
|
|
startLogin() |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
const newSetName = prompt(t('Enter a name for the new relay set')) |
|
|
|
const newSetName = prompt(t('Enter a name for the new relay set')) |
|
|
|
if (newSetName) { |
|
|
|
if (newSetName) { |
|
|
|
createRelaySet(newSetName, urls) |
|
|
|
createRelaySet(newSetName, urls) |
|
|
|
|