import classNames from 'classnames'; import { List as ImmutableList } from 'immutable'; import React, { useEffect, useState } from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { useDispatch } from 'react-redux'; import { useLocation } from 'react-router-dom'; import { fetchDirectory, expandDirectory } from 'soapbox/actions/directory'; import LoadMore from 'soapbox/components/load_more'; import RadioButton from 'soapbox/components/radio_button'; import Column from 'soapbox/features/ui/components/column'; import { useAppSelector } from 'soapbox/hooks'; import { getFeatures } from 'soapbox/utils/features'; import AccountCard from './components/account_card'; const messages = defineMessages({ title: { id: 'column.directory', defaultMessage: 'Browse profiles' }, recentlyActive: { id: 'directory.recently_active', defaultMessage: 'Recently active' }, newArrivals: { id: 'directory.new_arrivals', defaultMessage: 'New arrivals' }, local: { id: 'directory.local', defaultMessage: 'From {domain} only' }, federated: { id: 'directory.federated', defaultMessage: 'From known fediverse' }, }); const Directory = () => { const intl = useIntl(); const dispatch = useDispatch(); const { search } = useLocation(); const params = new URLSearchParams(search); const accountIds = useAppSelector((state) => state.user_lists.getIn(['directory', 'items'], ImmutableList())); const isLoading = useAppSelector((state) => state.user_lists.getIn(['directory', 'isLoading'], true)); const title = useAppSelector((state) => state.instance.get('title')); const features = useAppSelector((state) => getFeatures(state.instance)); const [order, setOrder] = useState(params.get('order') || 'active'); const [local, setLocal] = useState(!!params.get('local')); useEffect(() => { dispatch(fetchDirectory({ order: order || 'active', local: local || false })); }, [order, local]); const handleChangeOrder: React.ChangeEventHandler = e => { setOrder(e.target.value); }; const handleChangeLocal: React.ChangeEventHandler = e => { setLocal(e.target.value === '1'); }; const handleLoadMore = () => { dispatch(expandDirectory({ order: order || 'active', local: local || false })); }; return (
{features.federating && (
)}
{accountIds.map((accountId: string) => )}
); }; export default Directory;