fix(web): keep loading newer timeline days after reload #910
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/newer-days-hydration"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Root cause (empirically reproduced on the unpatched build)
After reloading into a restored mid-timeline window, scrolling up fired exactly one
revealPreviousDaysbatch and then stalled with the "Show newer days" button still visible:rootMargin: '900px 0px') fires only on intersection transitions. After a restore places the viewport far below the sentinel, the first upward approach consumes the single transition; the sentinel then stays inside the margin, so no further callbacks ever fire. In-session axis jumps mask this because days above are already hydrated.revealPreviousDaysearly-returned whenloadingVisibleDayswas true — a manual click or observer call landing during an in-flight batch was silently lost.Reproduced deterministically with a request-gated fixture: window frozen at
visibleDayStartIndex = 6, item requests frozen at 18, sentinel still in the margin.Fix (apps/web/src/routes/+page.svelte, minimal)
hydrateDays'sfinally(winningloadSequenceonly) now callsschedulePreviousDaysRevealCheck(), which aftertick()re-evaluates the margin condition (sentinel.getBoundingClientRect().top < innerHeight + 900) and re-triggersrevealPreviousDays()— a condition-driven loop that chains 8-day batches until the sentinel leaves the margin or the window reaches index 0.revealPreviousDaysno longer drops calls during in-flight loads: it setspendingPreviousDaysReveal, which the post-hydration check consumes.load()alongsidependingTimelineRefresh, so scope switches/reloads start clean.revealPreviousDaysScheduled), termination is condition-driven, and every cycle strictly decreases the window start index by 8 — finite by construction.pendingTimelineRefreshcycle, and #895 scroll-stability work unchanged; no API or MediaGrid changes.Verification
npm run check: 0 errors (20 pre-existing warnings).npm run build: success.npx playwright test tests/timeline.spec.ts(desktop + Pixel 7): 79 passed, 11 skipped, 0 failed, 0 flaky.timeline newer days hydration: auto-chain to index 0 without any click (asserts all 24 days fetched incl. day 0, which only the second chained batch requests) and a "Show newer days" click landing while a batch is in flight that must be remembered and completed.