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

@@ -1,6 +1,5 @@
import LoginDialog from '@/components/LoginDialog'
import { ApplicationDataKey, BIG_RELAY_URLS, ExtendedKind } from '@/constants'
import { useToast } from '@/hooks'
import { createSeenNotificationsAtDraftEvent } from '@/lib/draft-event'
import {
getLatestEvent,
@@ -20,11 +19,12 @@ import * as nip19 from 'nostr-tools/nip19'
import * as nip49 from 'nostr-tools/nip49'
import { createContext, useContext, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { toast } from 'sonner'
import { BunkerSigner } from './bunker.signer'
import { Nip07Signer } from './nip-07.signer'
import { NostrConnectionSigner } from './nostrConnection.signer'
import { NpubSigner } from './npub.signer'
import { NsecSigner } from './nsec.signer'
import { NostrConnectionSigner } from './nostrConnection.signer'
type TNostrContext = {
isInitialized: boolean
@@ -80,7 +80,6 @@ export const useNostr = () => {
export function NostrProvider({ children }: { children: React.ReactNode }) {
const { t } = useTranslation()
const { toast } = useToast()
const [account, setAccount] = useState<TAccountPointer | null>(null)
const [nsec, setNsec] = useState<string | null>(null)
const [ncryptsec, setNcryptsec] = useState<string | null>(null)
@@ -379,11 +378,7 @@ export function NostrProvider({ children }: { children: React.ReactNode }) {
}
return login(nip07Signer, { pubkey, signerType: 'nip-07' })
} catch (err) {
toast({
title: 'Login failed',
description: (err as Error).message,
variant: 'destructive'
})
toast.error(t('Login failed') + ': ' + (err as Error).message)
throw err
}
}