|
|
|
|
@ -65,7 +65,8 @@ async function fetchBadgeDefinitionOnRelays(
@@ -65,7 +65,8 @@ async function fetchBadgeDefinitionOnRelays(
|
|
|
|
|
{ |
|
|
|
|
replaceableRace: true, |
|
|
|
|
eoseTimeout: METADATA_BATCH_QUERY_EOSE_TIMEOUT_MS, |
|
|
|
|
globalTimeout: METADATA_BATCH_QUERY_GLOBAL_TIMEOUT_MS |
|
|
|
|
globalTimeout: METADATA_BATCH_QUERY_GLOBAL_TIMEOUT_MS, |
|
|
|
|
foreground: true |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
const matches = rows.filter((e) => e.kind === ExtendedKind.BADGE_DEFINITION) |
|
|
|
|
@ -110,8 +111,6 @@ export function useProfileWall(pubkey: string, profileEventId: string | undefine
@@ -110,8 +111,6 @@ export function useProfileWall(pubkey: string, profileEventId: string | undefine
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
let cancelled = false |
|
|
|
|
let idleHandle: number | undefined |
|
|
|
|
let idleTimeout: ReturnType<typeof setTimeout> | undefined |
|
|
|
|
|
|
|
|
|
const run = async () => { |
|
|
|
|
const mem = wallCacheByKey.get(cacheKey) |
|
|
|
|
@ -123,14 +122,18 @@ export function useProfileWall(pubkey: string, profileEventId: string | undefine
@@ -123,14 +122,18 @@ export function useProfileWall(pubkey: string, profileEventId: string | undefine
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setIsLoading(true) |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
const pkNorm = userIdToPubkey(pubkey) || pubkey |
|
|
|
|
if (!isValidPubkey(pkNorm)) { |
|
|
|
|
if (!cancelled) setIsLoading(false) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const emptyAuthor = { read: [] as string[], write: [] as string[], httpRead: [] as string[], httpWrite: [] as string[] } |
|
|
|
|
const emptyAuthor = { |
|
|
|
|
read: [] as string[], |
|
|
|
|
write: [] as string[], |
|
|
|
|
httpRead: [] as string[], |
|
|
|
|
httpWrite: [] as string[] |
|
|
|
|
} |
|
|
|
|
const authorRl = await client.peekRelayListFromStorage(pubkey).catch(() => emptyAuthor) |
|
|
|
|
if (cancelled) return |
|
|
|
|
|
|
|
|
|
@ -181,7 +184,8 @@ export function useProfileWall(pubkey: string, profileEventId: string | undefine
@@ -181,7 +184,8 @@ export function useProfileWall(pubkey: string, profileEventId: string | undefine
|
|
|
|
|
client.fetchEvents(relayUrls, filter, { |
|
|
|
|
cache: true, |
|
|
|
|
eoseTimeout: 4500, |
|
|
|
|
globalTimeout: 14_000 |
|
|
|
|
globalTimeout: 14_000, |
|
|
|
|
foreground: true |
|
|
|
|
}) |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
@ -209,26 +213,15 @@ export function useProfileWall(pubkey: string, profileEventId: string | undefine
@@ -209,26 +213,15 @@ export function useProfileWall(pubkey: string, profileEventId: string | undefine
|
|
|
|
|
comments: wallComments, |
|
|
|
|
lastUpdated: Date.now() |
|
|
|
|
}) |
|
|
|
|
setIsLoading(false) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const scheduleRun = () => { |
|
|
|
|
if (typeof requestIdleCallback === 'function') { |
|
|
|
|
idleHandle = requestIdleCallback(() => void run(), { timeout: 4_000 }) |
|
|
|
|
} else { |
|
|
|
|
idleTimeout = setTimeout(() => void run(), 400) |
|
|
|
|
} finally { |
|
|
|
|
if (!cancelled) setIsLoading(false) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
scheduleRun() |
|
|
|
|
|
|
|
|
|
void run() |
|
|
|
|
|
|
|
|
|
return () => { |
|
|
|
|
cancelled = true |
|
|
|
|
if (idleHandle !== undefined && typeof cancelIdleCallback === 'function') { |
|
|
|
|
cancelIdleCallback(idleHandle) |
|
|
|
|
} |
|
|
|
|
if (idleTimeout !== undefined) { |
|
|
|
|
clearTimeout(idleTimeout) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, [pubkey, profileEventId, cacheKey, refreshToken, relayListsKey]) |
|
|
|
|
|
|
|
|
|
|