revert(v2): hydrate gallery cards per-card via /roms/{id}/simple#3789
Merged
Conversation
The v2 gallery had been switched from per-card GET /roms/{id}/simple
hydration to batched window fetches because the /simple endpoint was
slow. Now that /simple is fast (lightweight eager-load), revert the
gallery back to per-card hydration: onMount fetches a single rom by id
and onUnmount aborts if the card scrolled out of view.
Reintroduces fetchRomAt / cancelFetchAt and drops the now-unreachable
window-fetch machinery (fetchWindowAt, syncVisibleWindows, the window
auto-retry, and the batched-apply helpers). Keeps the later
improvements: the withCharIndex / withFilterValues skip params on the
roms API and the abortInFlight store action.
Generated-By: PostHog Code
Task-Id: fe232494-3d20-4d83-9eaa-3ce341d4e7b5
Contributor
Greptile SummaryThis PR restores per-card hydration for the v2 gallery. The main changes are:
Confidence Score: 4/5The per-card hydration lifecycle can leave visible grid and list cards stuck as skeletons.
frontend/src/v2/stores/galleryRoms.ts and frontend/src/v2/components/Gallery/GameListRow.vue Important Files Changed
Reviews (1): Last reviewed commit: "revert(v2): hydrate gallery cards per-ca..." | Re-trigger Greptile |
A list row fetched its rom only in onMounted. A filter / search / sort / scan refresh clears byPosition and repopulates romIdIndex while the row stays mounted at the same position, so it was stranded on skeletons until it scrolled out and remounted. Replace the onMounted fetch with a watch that fires fetchRomAt whenever the position is missing its rom but the store knows its id. Guarding on the id (not just a null rom) also refetches when a resort lands a different rom at the same position. The store still dedupes against in-flight + already-loaded, so re-runs are cheap. Generated-By: PostHog Code Task-Id: fe232494-3d20-4d83-9eaa-3ce341d4e7b5
An aborted per-card fetch's finally deleted the inFlightControllers entry
unconditionally. If the position was cancelled and quickly re-entered the
viewport, a replacement request could store a new controller under the
same rom:${position} key before the aborted request reached finally; the
unconditional delete then removed the new controller, so its response
failed the ownership check and the card stayed a skeleton.
Compare controller identity in both the success re-check and the finally
delete (mirroring fetchInitialMetadata) so a request only ever clears its
own entry.
Generated-By: PostHog Code
Task-Id: fe232494-3d20-4d83-9eaa-3ce341d4e7b5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Explain the changes or enhancements you are proposing with this pull request.
The v2 gallery previously hydrated each visible card with its own
GET /roms/{id}/simplerequest. Because that endpoint was slow at the time, a prior change (#3765) switched hydration to batched 72-item window fetches through the paginated/romslist endpoint.Now that
/roms/{id}/simpleis fast (lightweight eager-load), this reverts the gallery back to per-card hydration:galleryRomsstore — reintroducesfetchRomAt(position)(per-cardGET /roms/{id}/simple) andcancelFetchAt(position). Removes the now-unreachable window-fetch machinery:fetchWindowAt,syncVisibleWindows,cancelWindow, the window auto-retry (retryTimers/retryCounts/backoff), the batched-apply helpers (applyItemsBatched/nextFrame),alignToWindow, theloadedWindows/pendingWindows/failedWindowsstate, and the unusedhasInitialgetter.GalleryShell— grid-mode viewport sync firesfetchRomAtfor entered positions andcancelFetchAtfor departed ones, restoring thevisiblePositionstracking set.GameListRow— row mount firesfetchRomAt, unmount aborts viacancelFetchAt.Kept from the intervening work, as intended:
withCharIndex/withFilterValuesskip params on the roms API (services/api/rom.tsuntouched),abortInFlightstore action, still wired into the shell's unmount.The lightweight
fetchInitialMetadatabootstrap (seedstotal/charIndex/romIdIndex/filter_values) is unchanged.AI assistance disclosure: This PR was written with AI assistance (PostHog Code / Claude). The change was reviewed by the author.
Checklist
Please check all that apply.
Screenshots (if applicable)
No UI/visual change; behavior-only revert of the hydration path.
Created with PostHog Code