harden human language initial load with staged retries
Run multiple delayed hierarchy retries on first tab navigation to prevent empty-state flicker and avoid requiring manual page refresh. Made-with: Cursor
This commit is contained in:
parent
a8e4ef76e9
commit
60a29816fb
|
|
@ -448,14 +448,18 @@ export function HumanLanguagePage() {
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
try {
|
try {
|
||||||
const count = await loadHierarchy(false)
|
// On first navigation after login, hierarchy can race token refresh and return empty.
|
||||||
// On first navigation after login, the first hierarchy request can race auth refresh.
|
// Retry a few times before showing empty state so manual browser refresh is not required.
|
||||||
// Retry once if it comes back empty so users don't need a manual browser refresh.
|
let loadedCount = 0
|
||||||
if (!cancelled && count === 0) {
|
const retryDelays = [0, 500, 900, 1400]
|
||||||
await new Promise((resolve) => setTimeout(resolve, 650))
|
for (const delay of retryDelays) {
|
||||||
if (!cancelled) {
|
if (cancelled) return
|
||||||
await loadHierarchy(false)
|
if (delay > 0) {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, delay))
|
||||||
|
if (cancelled) return
|
||||||
}
|
}
|
||||||
|
loadedCount = await loadHierarchy(false)
|
||||||
|
if (loadedCount > 0) break
|
||||||
}
|
}
|
||||||
const saved = sessionStorage.getItem(HUMAN_LANGUAGE_SCROLL_KEY)
|
const saved = sessionStorage.getItem(HUMAN_LANGUAGE_SCROLL_KEY)
|
||||||
const targetY = saved ? Number(saved) : 0
|
const targetY = saved ? Number(saved) : 0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user