Skip loading alt styles on item preview page

Ah yeah, if you're not on the wardrobe page (so we don't need the Alt
Styles UI), and the outfit's `altStyleId` is null (as is the case for
the item preview page), then there's no need to load the alt styles for
that species.

So before this change, going to `/items/123` would include an XHR
request to `/species/<id>/alt-styles.json`, which would not be used for
anything. After this change, that request is no longer sent. Hooray!
This commit is contained in:
Emi Matchu 2024-02-24 17:23:57 -08:00
parent 7af1a97161
commit 56d550e86c

View file

@ -12,7 +12,10 @@ export function useAltStylesForSpecies(speciesId, options = {}) {
// NOTE: This is actually just a wrapper for `useAltStylesForSpecies`, to share // NOTE: This is actually just a wrapper for `useAltStylesForSpecies`, to share
// the same cache key! // the same cache key!
export function useAltStyle(id, speciesId, options = {}) { export function useAltStyle(id, speciesId, options = {}) {
const query = useAltStylesForSpecies(speciesId, options); const query = useAltStylesForSpecies(speciesId, {
...options,
enabled: (options.enabled ?? true) && id != null,
});
return { return {
...query, ...query,