import React, { useEffect } from 'react'; import { NavLink } from 'react-router-dom'; import { createSelector } from 'reselect'; import { fetchLists } from 'soapbox/actions/lists'; import Icon from 'soapbox/components/icon'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import type { List as ImmutableList } from 'immutable'; import type { RootState } from 'soapbox/store'; import type { List as ListEntity } from 'soapbox/types/entities'; const getOrderedLists = createSelector([(state: RootState) => state.lists], lists => { if (!lists) { return lists; } return lists.toList().filter(item => !!item).sort((a, b) => (a as ListEntity).title.localeCompare((b as ListEntity).title)).take(4) as ImmutableList; }); const ListPanel = () => { const dispatch = useAppDispatch(); const lists = useAppSelector((state) => getOrderedLists(state)); useEffect(() => { dispatch(fetchLists()); }, []); if (!lists || lists.isEmpty()) { return null; } return (

{lists.map(list => ( {list.title} ))}
); }; export default ListPanel;