// @flow import React from 'react'; import ClaimList from 'component/claimList'; import ClaimListDiscover from 'component/claimListDiscover'; import DebouncedInput from 'component/common/debounced-input'; import Empty from 'component/common/empty'; import Page from 'component/page'; import Spinner from 'component/spinner'; import * as CS from 'constants/claim_search'; import * as ICONS from 'constants/icons'; import { parseURI } from 'util/lbryURI'; function getFilteredUris(uris, filterQuery) { if (filterQuery) { const filterQueryLowerCase = filterQuery.toLowerCase(); return uris.filter((uri) => uri.toLowerCase().includes(filterQueryLowerCase)); } return null; } function parseIdFromUri(uri) { try { const { channelClaimId } = parseURI(uri); return channelClaimId; } catch { return ''; } } // **************************************************************************** // ChannelsFollowingManage // **************************************************************************** type Props = { subscribedChannelUris: Array, }; export default function ChannelsFollowingManage(props: Props) { const { subscribedChannelUris } = props; const [uris, setUris] = React.useState([]); const [filterQuery, setFilterQuery] = React.useState(''); const filteredUris = getFilteredUris(uris, filterQuery); const [channelIds, setChannelIds] = React.useState(null); React.useEffect(() => { setUris(subscribedChannelUris); setChannelIds(subscribedChannelUris.map((uri) => parseIdFromUri(uri))); // eslint-disable-next-line react-hooks/exhaustive-deps, (lock list on mount so it doesn't shift when unfollow) }, []); return (
{__('Followed Channels')}
{channelIds === null ? (
) : uris && uris.length === 0 ? ( ) : ( <> {filteredUris && } {!filteredUris && channelIds.length && ( )} )}
); }