Browse Source

feat: check login status before saving relays

imwald
codytseng 7 months ago
parent
commit
f9cbcda7e8
  1. 11
      src/components/SaveRelayDropdownMenu/index.tsx

11
src/components/SaveRelayDropdownMenu/index.tsx

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

Loading…
Cancel
Save