Skip to content

Commit

Permalink
chore: use react query enabled param EB-832
Browse files Browse the repository at this point in the history
  • Loading branch information
Orion Wolf-Hubbard committed Jan 9, 2025
1 parent 32b7285 commit e8a8bc3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions packages/favorites/src/lib/Favorites.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ export const FavoritesProvider = ({
const [lastClickedFavoriteId, setLastClickedFavoriteId] = useState<string>('');

const queryClient = useQueryClient();
const { data: favorites, status: queryStatus } = settingsStatus ? {
data: settingsFavorites,
status: settingsStatus,
} : useFavoritesQuery();
const { data: favoritesData, status: favoritesDataStatus } = useFavoritesQuery(!settingsStatus);
const favorites = settingsStatus ? settingsFavorites : favoritesData;
const queryStatus = settingsStatus ? settingsStatus : favoritesDataStatus;

const { submitFavorites, status: mutationStatus } = useSubmitFavorites({
onMutationStart(targetFavoriteId) {
Expand Down
2 changes: 1 addition & 1 deletion packages/favorites/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const getFavorites = async () => {
return validatedFavorites;
};

export const useFavoritesQuery = (): UseQueryResult<Favorite[], unknown> => useQuery(['favorites'], getFavorites);
export const useFavoritesQuery = (enabled: boolean): UseQueryResult<Favorite[], unknown> => useQuery(['favorites'], getFavorites, { enabled });

type MutationOptions = {
onMutationStart?: (targetFavoriteId: string) => void;
Expand Down

0 comments on commit e8a8bc3

Please sign in to comment.