Skip to content

Commit

Permalink
Fix missing items on spell page
Browse files Browse the repository at this point in the history
  • Loading branch information
sandervspl committed Aug 6, 2024
1 parent 281bbeb commit 8ef11db
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions apps/extension/src/hooks/useItemsFetcher.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import * as i from 'types';
import { skipToken, useQueries } from '@tanstack/react-query';
import { useQueries } from '@tanstack/react-query';

import { fetchItemFromAPI } from '@/queries/item';

import useUser from './useUser';
import { useWowhead } from './useWowhead';
import { getItemFromStorage } from '@/utils/storage';

export function useItemsFetcher(itemIds: number[], auctionHouseId: number) {
const user = useUser();
const { version } = useWowhead();

return useQueries({
Expand All @@ -20,17 +18,14 @@ export function useItemsFetcher(itemIds: number[], auctionHouseId: number) {
itemId,
} as i.CachedItemDataClassic,
queryFn: async () => {
if (!user.realm || !user.faction) {
return;
}

// Check browser storage if item is stored
const cachedItem = getItemFromStorage(user.realm!.auctionHouseId, itemId);
const cachedItem = await getItemFromStorage(auctionHouseId, itemId);

if (cachedItem) {
return cachedItem;
}

const fetchedItem = await fetchItemFromAPI(itemId, user.realm.auctionHouseId, version);
const fetchedItem = await fetchItemFromAPI(itemId, auctionHouseId, version);

if (fetchedItem === 'NOT_FOUND' || fetchedItem === undefined) {
return {
Expand Down

0 comments on commit 8ef11db

Please sign in to comment.