From 4ddc5b38d16503ef36702e7ae4090825aaee2fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sat, 9 Nov 2024 23:40:51 +0100 Subject: [PATCH] pl-fe: migrate trending links to tanstack query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- .../src/api/hooks/trends/use-trending-links.ts | 18 +++++++----------- .../search/components/search-results.tsx | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/packages/pl-fe/src/api/hooks/trends/use-trending-links.ts b/packages/pl-fe/src/api/hooks/trends/use-trending-links.ts index 9d7d31fc3..e8b830e26 100644 --- a/packages/pl-fe/src/api/hooks/trends/use-trending-links.ts +++ b/packages/pl-fe/src/api/hooks/trends/use-trending-links.ts @@ -1,21 +1,17 @@ -import { Entities } from 'pl-fe/entity-store/entities'; -import { useEntities } from 'pl-fe/entity-store/hooks/use-entities'; +import { useQuery } from '@tanstack/react-query'; + import { useClient } from 'pl-fe/hooks/use-client'; import { useFeatures } from 'pl-fe/hooks/use-features'; -import type { TrendsLink } from 'pl-api'; - const useTrendingLinks = () => { const client = useClient(); const features = useFeatures(); - const { entities, ...rest } = useEntities( - [Entities.TRENDS_LINKS], - () => client.trends.getTrendingLinks(), - { enabled: features.trendingLinks }, - ); - - return { trendingLinks: entities, ...rest }; + return useQuery({ + queryKey: ['trends', 'links'], + queryFn: () => client.trends.getTrendingLinks(), + enabled: features.trendingLinks, + }); }; export { useTrendingLinks }; diff --git a/packages/pl-fe/src/features/search/components/search-results.tsx b/packages/pl-fe/src/features/search/components/search-results.tsx index 53d0ad0ac..664038909 100644 --- a/packages/pl-fe/src/features/search/components/search-results.tsx +++ b/packages/pl-fe/src/features/search/components/search-results.tsx @@ -68,7 +68,7 @@ const SearchResults = () => { const suggestions = useAppSelector((state) => state.suggestions.items); const { data: trendingTags } = useTrends(); const { data: trendingStatuses } = useTrendingStatuses(); - const { trendingLinks } = useTrendingLinks(); + const { data: trendingLinks } = useTrendingLinks(); const { account } = useAccount(accountId); const handleUnsetAccount = () => {