fix: 🐛
This commit is contained in:
@@ -34,7 +34,7 @@ export const useFeed = () => {
|
|||||||
|
|
||||||
export function FeedProvider({ children }: { children: React.ReactNode }) {
|
export function FeedProvider({ children }: { children: React.ReactNode }) {
|
||||||
const isFirstRenderRef = useRef(true)
|
const isFirstRenderRef = useRef(true)
|
||||||
const { pubkey } = useNostr()
|
const { pubkey, isInitialized } = useNostr()
|
||||||
const { relaySets, favoriteRelays } = useFavoriteRelays()
|
const { relaySets, favoriteRelays } = useFavoriteRelays()
|
||||||
const [relayUrls, setRelayUrls] = useState<string[]>([])
|
const [relayUrls, setRelayUrls] = useState<string[]>([])
|
||||||
const [temporaryRelayUrls, setTemporaryRelayUrls] = useState<string[]>([])
|
const [temporaryRelayUrls, setTemporaryRelayUrls] = useState<string[]>([])
|
||||||
@@ -66,6 +66,10 @@ export function FeedProvider({ children }: { children: React.ReactNode }) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isInitialized) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let feedInfo: TFeedInfo = {
|
let feedInfo: TFeedInfo = {
|
||||||
feedType: 'relay',
|
feedType: 'relay',
|
||||||
id: favoriteRelays[0] ?? DEFAULT_FAVORITE_RELAYS[0]
|
id: favoriteRelays[0] ?? DEFAULT_FAVORITE_RELAYS[0]
|
||||||
@@ -92,7 +96,7 @@ export function FeedProvider({ children }: { children: React.ReactNode }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init()
|
init()
|
||||||
}, [pubkey])
|
}, [pubkey, isInitialized])
|
||||||
|
|
||||||
const switchFeed = async (
|
const switchFeed = async (
|
||||||
feedType: TFeedType,
|
feedType: TFeedType,
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user