Skip to content

Commit d4018e5

Browse files
committed
fix(v2): skip metadata aggregations on later gallery windows
Once the bootstrap or window 0 has populated the filter panel, alpha strip, and id index, later window fetches only need their paged items. Send with_char_index=false and with_filter_values=false so the backend doesn't recompute those aggregations for every window. Generated-By: PostHog Code Task-Id: daf23950-b84a-4537-971c-3f85425c172c
1 parent 79f350a commit d4018e5

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

frontend/src/services/api/rom.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ export interface GetRomsParams {
182182
playerCountsLogic?: string | null;
183183
metadataProvidersLogic?: string | null;
184184
tagsLogic?: string | null;
185+
// Skip the char index / filter-value aggregations server-side. Left
186+
// undefined (the server default is `true`) unless a caller has already
187+
// hydrated that metadata and only wants the paged items.
188+
withCharIndex?: boolean;
189+
withFilterValues?: boolean;
185190
// Cancellation: pass an AbortSignal to let the caller abort an
186191
// in-flight request (e.g. search-typing → previous query aborted,
187192
// gallery-context switch → previous platform's windows aborted).
@@ -231,6 +236,8 @@ async function getRoms({
231236
playerCountsLogic = null,
232237
metadataProvidersLogic = null,
233238
tagsLogic = null,
239+
withCharIndex = undefined,
240+
withFilterValues = undefined,
234241
signal = undefined,
235242
}: GetRomsParams) {
236243
const params = {
@@ -336,6 +343,10 @@ async function getRoms({
336343
...(filterSaves !== null ? { has_saves: filterSaves } : {}),
337344
...(filterStates !== null ? { has_states: filterStates } : {}),
338345
...(filterVerified !== null ? { verified: filterVerified } : {}),
346+
...(withCharIndex !== undefined ? { with_char_index: withCharIndex } : {}),
347+
...(withFilterValues !== undefined
348+
? { with_filter_values: withFilterValues }
349+
: {}),
339350
};
340351

341352
return api.get<GetRomsResponse>(`/roms`, {

frontend/src/v2/stores/galleryRoms.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,18 @@ export default defineStore("v2GalleryRoms", {
460460
const controller = new AbortController();
461461
inFlightControllers.set(ctrlKey, controller);
462462

463+
// Once the bootstrap (or window 0) has populated the filter panel,
464+
// alpha strip, and id index, later windows only need their paged
465+
// items — skip the char index / filter-value aggregations so the
466+
// backend doesn't recompute them for every window.
467+
const skipMetadata = this.metadataLoaded;
468+
463469
try {
464470
const response = await romApi.getRoms({
465471
...params,
472+
...(skipMetadata
473+
? { withCharIndex: false, withFilterValues: false }
474+
: {}),
466475
signal: controller.signal,
467476
});
468477
// Re-check that this window is still relevant — invalidateWindows

0 commit comments

Comments
 (0)