Favourites: unavailable --> isUnavailable, move useEffect's down

This commit is contained in:
Alex Gleason 2022-09-12 10:14:57 -05:00
parent 0355d2a927
commit 74d2325b58
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -38,11 +38,19 @@ const Favourites: React.FC<IFavourites> = (props) => {
const isLoading = useAppSelector(state => state.status_lists.get(timelineKey)?.isLoading === true); const isLoading = useAppSelector(state => state.status_lists.get(timelineKey)?.isLoading === true);
const hasMore = useAppSelector(state => !!state.status_lists.get(timelineKey)?.next); const hasMore = useAppSelector(state => !!state.status_lists.get(timelineKey)?.next);
const unavailable = useAppSelector(state => { const isUnavailable = useAppSelector(state => {
const blockedBy = state.relationships.getIn([account?.id, 'blocked_by']) === true; const blockedBy = state.relationships.getIn([account?.id, 'blocked_by']) === true;
return isOwnAccount ? false : (blockedBy && !features.blockersVisible); return isOwnAccount ? false : (blockedBy && !features.blockersVisible);
}); });
const handleLoadMore = useCallback(debounce(() => {
if (isOwnAccount) {
dispatch(expandFavouritedStatuses());
} else if (account) {
dispatch(expandAccountFavouritedStatuses(account.id));
}
}, 300, { leading: true }), [account?.id]);
useEffect(() => { useEffect(() => {
if (isOwnAccount) if (isOwnAccount)
dispatch(fetchFavouritedStatuses()); dispatch(fetchFavouritedStatuses());
@ -63,15 +71,7 @@ const Favourites: React.FC<IFavourites> = (props) => {
} }
}, [account?.id]); }, [account?.id]);
const handleLoadMore = useCallback(debounce(() => { if (isUnavailable) {
if (isOwnAccount) {
dispatch(expandFavouritedStatuses());
} else if (account) {
dispatch(expandAccountFavouritedStatuses(account.id));
}
}, 300, { leading: true }), [account?.id]);
if (unavailable) {
return ( return (
<Column> <Column>
<div className='empty-column-indicator'> <div className='empty-column-indicator'>