Support Mastodon trending links

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-08-20 12:42:06 +02:00
parent 236e4db1a9
commit 838ace63d9
13 changed files with 141 additions and 29 deletions

View File

@ -44,3 +44,6 @@ export { useHashtagStream } from './streaming/useHashtagStream';
export { useListStream } from './streaming/useListStream';
export { useGroupStream } from './streaming/useGroupStream';
export { useRemoteStream } from './streaming/useRemoteStream';
// Trends
export { useTrendingLinks } from './trends/useTrendingLinks';

View File

@ -0,0 +1,20 @@
import { trendsLinkSchema } from 'pl-api';
import { Entities } from 'soapbox/entity-store/entities';
import { useEntities } from 'soapbox/entity-store/hooks';
import { useClient, useFeatures } from 'soapbox/hooks';
const useTrendingLinks = () => {
const client = useClient();
const features = useFeatures();
const { entities, ...rest } = useEntities(
[Entities.TRENDS_LINKS],
() => client.trends.getTrendingLinks(),
{ schema: trendsLinkSchema, enabled: features.trendingLinks },
);
return { trendingLinks: entities, ...rest };
};
export { useTrendingLinks };