perf(pokemon): cache fetch options locally to reduce API requests
Add `all` parameter to fetch-options API to retrieve the full list. Fetch all options once and filter locally in the Pokemon edit view to improve search responsiveness.
This commit is contained in:
@@ -1008,8 +1008,11 @@ export const api = {
|
||||
pokemon: (params: Record<string, string | number | undefined>) =>
|
||||
getJson<Pokemon[]>(`/api/pokemon${buildQuery(params)}`),
|
||||
pokemonDetail: (id: string | number) => getJson<PokemonDetail>(`/api/pokemon/${id}`),
|
||||
pokemonFetchOptions: (search: string, signal?: AbortSignal) =>
|
||||
getJson<PokemonFetchOption[]>(`/api/pokemon/fetch-options${buildQuery({ search: search.trim() })}`, signal),
|
||||
pokemonFetchOptions: (search: string, signal?: AbortSignal, all = false) =>
|
||||
getJson<PokemonFetchOption[]>(
|
||||
`/api/pokemon/fetch-options${buildQuery({ search: search.trim(), all: all ? true : undefined })}`,
|
||||
signal
|
||||
),
|
||||
fetchPokemonData: (identifier: string) => sendJson<PokemonFetchResult>('/api/pokemon/fetch', 'POST', { identifier }),
|
||||
fetchPokemonImageOptions: (identifier: string) =>
|
||||
sendJson<PokemonImageOptionsResult>('/api/pokemon/image-options', 'POST', { identifier }),
|
||||
|
||||
Reference in New Issue
Block a user