2022-05-13 14:14:55 -07:00
import { OrderedSet as ImmutableOrderedSet } from 'immutable' ;
import React from 'react' ;
import { FormattedMessage } from 'react-intl' ;
2022-11-15 08:00:49 -08:00
import ScrollableList from 'soapbox/components/scrollable-list' ;
2022-05-13 14:14:55 -07:00
import { Modal , Spinner } from 'soapbox/components/ui' ;
2022-11-15 08:13:54 -08:00
import AccountContainer from 'soapbox/containers/account-container' ;
2022-05-13 14:14:55 -07:00
import { useAppSelector } from 'soapbox/hooks' ;
import { makeGetAccount } from 'soapbox/selectors' ;
const getAccount = makeGetAccount ( ) ;
interface IFamiliarFollowersModal {
2023-02-15 13:26:27 -08:00
accountId : string
onClose : ( string : string ) = > void
2022-05-13 14:14:55 -07:00
}
const FamiliarFollowersModal = ( { accountId , onClose } : IFamiliarFollowersModal ) = > {
const account = useAppSelector ( state = > getAccount ( state , accountId ) ) ;
2022-06-21 15:29:17 -07:00
const familiarFollowerIds : ImmutableOrderedSet < string > = useAppSelector ( state = > state . user_lists . familiar_followers . get ( accountId ) ? . items || ImmutableOrderedSet ( ) ) ;
2022-05-13 14:14:55 -07:00
const onClickClose = ( ) = > {
onClose ( 'FAMILIAR_FOLLOWERS' ) ;
} ;
let body ;
if ( ! account || ! familiarFollowerIds ) {
body = < Spinner / > ;
} else {
const emptyMessage = < FormattedMessage id = 'account.familiar_followers.empty' defaultMessage = 'No one you know follows {name}.' values = { { name : < span dangerouslySetInnerHTML = { { __html : account.display_name_html } } / > } } / > ;
body = (
< ScrollableList
scrollKey = 'familiar_followers'
emptyMessage = { emptyMessage }
itemClassName = 'pb-3'
2023-06-27 10:41:05 -07:00
style = { { height : '80vh' } }
useWindowScroll = { false }
2022-05-13 14:14:55 -07:00
>
{ familiarFollowerIds . map ( id = >
< AccountContainer key = { id } id = { id } / > ,
) }
< / ScrollableList >
) ;
}
return (
< Modal
title = { < FormattedMessage id = 'column.familiar_followers' defaultMessage = 'People you know following {name}' values = { { name : < span dangerouslySetInnerHTML = { { __html : account?.display_name_html || '' } } / > } } / > }
onClose = { onClickClose }
>
{ body }
< / Modal >
) ;
} ;
export default FamiliarFollowersModal ;