diff --git a/app/soapbox/actions/timelines.ts b/app/soapbox/actions/timelines.ts index 74622d180..f1e9f5634 100644 --- a/app/soapbox/actions/timelines.ts +++ b/app/soapbox/actions/timelines.ts @@ -140,9 +140,15 @@ const parseTags = (tags: Record = {}, mode: 'any' | 'all' | 'none const replaceHomeTimeline = ( accountId: string | null, { maxId }: Record = {}, + done?: () => void, ) => (dispatch: AppDispatch, _getState: () => RootState) => { dispatch({ type: TIMELINE_REPLACE, accountId }); - dispatch(expandHomeTimeline({ accountId, maxId }, () => dispatch(insertSuggestionsIntoTimeline()))); + dispatch(expandHomeTimeline({ accountId, maxId }, () => { + dispatch(insertSuggestionsIntoTimeline()); + if (done) { + done(); + } + })); }; const expandTimeline = (timelineId: string, path: string, params: Record = {}, done = noOp) => diff --git a/app/soapbox/features/feed-filtering/feed-carousel.tsx b/app/soapbox/features/feed-filtering/feed-carousel.tsx index 59c6776ba..d64c6f8f0 100644 --- a/app/soapbox/features/feed-filtering/feed-carousel.tsx +++ b/app/soapbox/features/feed-filtering/feed-carousel.tsx @@ -15,13 +15,24 @@ const CarouselItem = ({ avatar }: { avatar: any }) => { const selectedAccountId = useAppSelector(state => state.timelines.get('home')?.feedAccountId); const isSelected = avatar.account_id === selectedAccountId; - const handleClick = () => - isSelected - ? dispatch(replaceHomeTimeline(null, { maxId: null })) - : dispatch(replaceHomeTimeline(avatar.account_id, { maxId: null })); + const [isLoading, setLoading] = useState(false); + + const handleClick = () => { + if (isLoading) { + return; + } + + setLoading(true); + + if (isSelected) { + dispatch(replaceHomeTimeline(null, { maxId: null }, () => setLoading(false))); + } else { + dispatch(replaceHomeTimeline(avatar.account_id, { maxId: null }, () => setLoading(false))); + } + }; return ( -
+
{isSelected && (