|
|
|
@ -24,6 +24,7 @@ import { NsecSigner } from './nsec.signer' |
|
|
|
import { NpubSigner } from './npub.signer' |
|
|
|
import { NpubSigner } from './npub.signer' |
|
|
|
|
|
|
|
|
|
|
|
type TNostrContext = { |
|
|
|
type TNostrContext = { |
|
|
|
|
|
|
|
isInitialized: boolean |
|
|
|
pubkey: string | null |
|
|
|
pubkey: string | null |
|
|
|
profile: TProfile | null |
|
|
|
profile: TProfile | null |
|
|
|
profileEvent: Event | null |
|
|
|
profileEvent: Event | null |
|
|
|
@ -83,6 +84,7 @@ export function NostrProvider({ children }: { children: React.ReactNode }) { |
|
|
|
const [followListEvent, setFollowListEvent] = useState<Event | undefined>(undefined) |
|
|
|
const [followListEvent, setFollowListEvent] = useState<Event | undefined>(undefined) |
|
|
|
const [muteListEvent, setMuteListEvent] = useState<Event | undefined>(undefined) |
|
|
|
const [muteListEvent, setMuteListEvent] = useState<Event | undefined>(undefined) |
|
|
|
const [favoriteRelaysEvent, setFavoriteRelaysEvent] = useState<Event | null>(null) |
|
|
|
const [favoriteRelaysEvent, setFavoriteRelaysEvent] = useState<Event | null>(null) |
|
|
|
|
|
|
|
const [isInitialized, setIsInitialized] = useState(false) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
const init = async () => { |
|
|
|
const init = async () => { |
|
|
|
@ -96,7 +98,9 @@ export function NostrProvider({ children }: { children: React.ReactNode }) { |
|
|
|
|
|
|
|
|
|
|
|
await loginWithAccountPointer(act) |
|
|
|
await loginWithAccountPointer(act) |
|
|
|
} |
|
|
|
} |
|
|
|
init() |
|
|
|
init().then(() => { |
|
|
|
|
|
|
|
setIsInitialized(true) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const handleHashChange = () => { |
|
|
|
const handleHashChange = () => { |
|
|
|
if (hasNostrLoginHash()) { |
|
|
|
if (hasNostrLoginHash()) { |
|
|
|
@ -537,6 +541,7 @@ export function NostrProvider({ children }: { children: React.ReactNode }) { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<NostrContext.Provider |
|
|
|
<NostrContext.Provider |
|
|
|
value={{ |
|
|
|
value={{ |
|
|
|
|
|
|
|
isInitialized, |
|
|
|
pubkey: account?.pubkey ?? null, |
|
|
|
pubkey: account?.pubkey ?? null, |
|
|
|
profile, |
|
|
|
profile, |
|
|
|
profileEvent, |
|
|
|
profileEvent, |
|
|
|
|