refactor: toast

This commit is contained in:
codytseng
2025-06-19 23:09:07 +08:00
parent 697b8e4663
commit ef2f8b357d
33 changed files with 127 additions and 477 deletions

View File

@@ -3,12 +3,13 @@ import RelayInfo from '@/components/RelayInfo'
import SaveRelayDropdownMenu from '@/components/SaveRelayDropdownMenu'
import SearchInput from '@/components/SearchInput'
import { Button } from '@/components/ui/button'
import { useFetchRelayInfo, useToast } from '@/hooks'
import { useFetchRelayInfo } from '@/hooks'
import SecondaryPageLayout from '@/layouts/SecondaryPageLayout'
import { normalizeUrl, simplifyUrl } from '@/lib/url'
import { Check, Copy, Link } from 'lucide-react'
import { forwardRef, useEffect, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { toast } from 'sonner'
import NotFoundPage from '../NotFoundPage'
const RelayPage = forwardRef(({ url, index }: { url?: string; index?: number }, ref) => {
@@ -63,7 +64,6 @@ RelayPage.displayName = 'RelayPage'
export default RelayPage
function RelayPageControls({ url }: { url: string }) {
const { toast } = useToast()
const [copiedUrl, setCopiedUrl] = useState(false)
const [copiedShareableUrl, setCopiedShareableUrl] = useState(false)
@@ -76,10 +76,7 @@ function RelayPageControls({ url }: { url: string }) {
const handleCopyShareableUrl = () => {
navigator.clipboard.writeText(`https://jumble.social/?r=${url}`)
setCopiedShareableUrl(true)
toast({
title: 'Shareable URL copied to clipboard',
description: 'You can share this URL with others.'
})
toast.success('Shareable URL copied to clipboard')
setTimeout(() => setCopiedShareableUrl(false), 2000)
}

View File

@@ -1,17 +1,16 @@
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import { useToast } from '@/hooks'
import { isEmail } from '@/lib/common'
import { createProfileDraftEvent } from '@/lib/draft-event'
import { useNostr } from '@/providers/NostrProvider'
import { Loader } from 'lucide-react'
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { toast } from 'sonner'
export default function LightningAddressInput() {
const { t } = useTranslation()
const { toast } = useToast()
const { profile, profileEvent, publish, updateProfileEvent } = useNostr()
const [lightningAddress, setLightningAddress] = useState('')
const [hasChanged, setHasChanged] = useState(false)
@@ -36,11 +35,7 @@ export default function LightningAddressInput() {
} else if (isEmail(lightningAddress)) {
lud16 = lightningAddress
} else {
toast({
title: 'Invalid Lightning Address',
description: 'Please enter a valid Lightning Address or LNURL',
variant: 'destructive'
})
toast.error(t('Invalid Lightning Address. Please enter a valid Lightning Address or LNURL.'))
setSaving(false)
return
}