import { formatListBullets, Icon } from '@wordpress/icons'; import { useTranslate } from 'i18n-calypso'; import { useEffect, useState } from 'react'; import { connect } from 'react-redux'; import EmptyContent from 'calypso/components/empty-content'; import { UserData } from 'calypso/lib/user/user'; import { List } from 'calypso/reader/list-manage/types'; import { requestUserLists } from 'calypso/state/reader/lists/actions'; interface AppState { reader: { lists: { userLists: Record< string, List[] >; isRequestingUserLists: Record< string, boolean >; }; }; } interface UserListsProps { user: UserData; requestUserLists?: ( userLogin: string ) => void; lists?: List[]; isLoading?: boolean; } export const UserLists = ( { user, requestUserLists, lists, isLoading, }: UserListsProps ): JSX.Element => { const translate = useTranslate(); const [ hasRequested, setHasRequested ] = useState( false ); const userLogin = user.user_login; useEffect( () => { if ( ! hasRequested && requestUserLists && userLogin ) { requestUserLists( userLogin ); setHasRequested( true ); } }, [ userLogin, requestUserLists, hasRequested ] ); if ( isLoading || ! hasRequested ) { return <>>; } if ( ! lists || lists.length === 0 ) { return (