Remove sort

This commit is contained in:
Justin 2022-08-10 11:33:23 -04:00
parent b377689ed2
commit 06d1ad2efe

View file

@ -12,21 +12,13 @@ interface ITrendsPanel {
const TrendsPanel = ({ limit }: ITrendsPanel) => {
const { data: trends, isFetching } = useTrends();
const sortedTrends = React.useMemo(() => {
return trends?.sort((a, b) => {
const num_a = Number(a.getIn(['history', 0, 'accounts']));
const num_b = Number(b.getIn(['history', 0, 'accounts']));
return num_b - num_a;
}).slice(0, limit);
}, [trends, limit]);
if (trends?.length === 0 || isFetching) {
return null;
}
return (
<Widget title={<FormattedMessage id='trends.title' defaultMessage='Trends' />}>
{sortedTrends?.slice(0, limit).map((hashtag) => (
{trends?.slice(0, limit).map((hashtag) => (
<Hashtag key={hashtag.name} hashtag={hashtag} />
))}
</Widget>