pl-fe: migrate trending links to tanstack query

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-11-09 23:40:51 +01:00
parent 1d76c05844
commit 4ddc5b38d1
2 changed files with 8 additions and 12 deletions

View file

@ -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<TrendsLink>(
[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 };

View file

@ -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 = () => {