fix: 🐛

This commit is contained in:
codytseng
2025-04-05 21:08:52 +08:00
parent 0c937d97cd
commit 2b9de01905
2 changed files with 12 additions and 3 deletions

View File

@@ -34,7 +34,7 @@ export const useFeed = () => {
export function FeedProvider({ children }: { children: React.ReactNode }) {
const isFirstRenderRef = useRef(true)
const { pubkey } = useNostr()
const { pubkey, isInitialized } = useNostr()
const { relaySets, favoriteRelays } = useFavoriteRelays()
const [relayUrls, setRelayUrls] = useState<string[]>([])
const [temporaryRelayUrls, setTemporaryRelayUrls] = useState<string[]>([])
@@ -66,6 +66,10 @@ export function FeedProvider({ children }: { children: React.ReactNode }) {
return
}
if (!isInitialized) {
return
}
let feedInfo: TFeedInfo = {
feedType: 'relay',
id: favoriteRelays[0] ?? DEFAULT_FAVORITE_RELAYS[0]
@@ -92,7 +96,7 @@ export function FeedProvider({ children }: { children: React.ReactNode }) {
}
init()
}, [pubkey])
}, [pubkey, isInitialized])
const switchFeed = async (
feedType: TFeedType,

View File

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