pl-fe: migrate trending links to tanstack query
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
1d76c05844
commit
4ddc5b38d1
2 changed files with 8 additions and 12 deletions
|
@ -1,21 +1,17 @@
|
||||||
import { Entities } from 'pl-fe/entity-store/entities';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { useEntities } from 'pl-fe/entity-store/hooks/use-entities';
|
|
||||||
import { useClient } from 'pl-fe/hooks/use-client';
|
import { useClient } from 'pl-fe/hooks/use-client';
|
||||||
import { useFeatures } from 'pl-fe/hooks/use-features';
|
import { useFeatures } from 'pl-fe/hooks/use-features';
|
||||||
|
|
||||||
import type { TrendsLink } from 'pl-api';
|
|
||||||
|
|
||||||
const useTrendingLinks = () => {
|
const useTrendingLinks = () => {
|
||||||
const client = useClient();
|
const client = useClient();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
|
|
||||||
const { entities, ...rest } = useEntities<TrendsLink>(
|
return useQuery({
|
||||||
[Entities.TRENDS_LINKS],
|
queryKey: ['trends', 'links'],
|
||||||
() => client.trends.getTrendingLinks(),
|
queryFn: () => client.trends.getTrendingLinks(),
|
||||||
{ enabled: features.trendingLinks },
|
enabled: features.trendingLinks,
|
||||||
);
|
});
|
||||||
|
|
||||||
return { trendingLinks: entities, ...rest };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export { useTrendingLinks };
|
export { useTrendingLinks };
|
||||||
|
|
|
@ -68,7 +68,7 @@ const SearchResults = () => {
|
||||||
const suggestions = useAppSelector((state) => state.suggestions.items);
|
const suggestions = useAppSelector((state) => state.suggestions.items);
|
||||||
const { data: trendingTags } = useTrends();
|
const { data: trendingTags } = useTrends();
|
||||||
const { data: trendingStatuses } = useTrendingStatuses();
|
const { data: trendingStatuses } = useTrendingStatuses();
|
||||||
const { trendingLinks } = useTrendingLinks();
|
const { data: trendingLinks } = useTrendingLinks();
|
||||||
const { account } = useAccount(accountId);
|
const { account } = useAccount(accountId);
|
||||||
|
|
||||||
const handleUnsetAccount = () => {
|
const handleUnsetAccount = () => {
|
||||||
|
|
Loading…
Reference in a new issue