Only show subscription filter when more subs than initial limit

This commit is contained in:
David Granado 2022-01-27 22:25:31 -06:00 committed by Thomas Zarebczan
parent 652d98f6c6
commit c7a23058c8
2 changed files with 8 additions and 6 deletions

View file

@ -6,15 +6,15 @@ import useDebounce from 'effects/use-debounce';
const FILTER_DEBOUNCE_MS = 300;
interface Props {
defaultValue?: string;
icon?: string;
value?: string;
placeholder?: string;
onChange: (newValue: string) => any;
}
export default function DebouncedInput(props: Props) {
const { icon, value = '', placeholder = '', onChange } = props;
const [rawValue, setRawValue] = useState(value);
const { defaultValue = '', icon, placeholder = '', onChange } = props;
const [rawValue, setRawValue] = useState(defaultValue);
const debouncedValue: string = useDebounce(rawValue, FILTER_DEBOUNCE_MS);
useEffect(() => {

View file

@ -304,9 +304,11 @@ function SideNavigation(props: Props) {
return (
<>
<ul className="navigation__secondary navigation-links">
<li className="navigation-item">
<DebouncedInput icon={ICONS.SEARCH} placeholder={__('Filter')} onChange={setSubscriptionFilter} />
</li>
{subscriptions.length > FOLLOWED_ITEM_INITIAL_LIMIT && (
<li className="navigation-item">
<DebouncedInput icon={ICONS.SEARCH} placeholder={__('Filter')} onChange={setSubscriptionFilter} />
</li>
)}
{displayedSubscriptions.map((subscription) => (
<SubscriptionListItem key={subscription.uri} subscription={subscription} />
))}