diff --git a/app/soapbox/features/feed-filtering/feed-carousel.tsx b/app/soapbox/features/feed-filtering/feed-carousel.tsx index 27b23a503..19e1c3400 100644 --- a/app/soapbox/features/feed-filtering/feed-carousel.tsx +++ b/app/soapbox/features/feed-filtering/feed-carousel.tsx @@ -1,5 +1,5 @@ import classNames from 'clsx'; -import React, { useEffect, useMemo, useState } from 'react'; +import React, { useEffect, useMemo, useRef, useState } from 'react'; import { FormattedMessage } from 'react-intl'; import { replaceHomeTimeline } from 'soapbox/actions/timelines'; @@ -11,7 +11,7 @@ import PlaceholderAvatar from '../placeholder/components/placeholder-avatar'; const CarouselItem = React.forwardRef(( { avatar, seen, onViewed, onPinned }: { avatar: Avatar, seen: boolean, onViewed: (account_id: string) => void, onPinned?: (avatar: null | Avatar) => void }, - ref: any, + ref: React.ForwardedRef, ) => { const dispatch = useAppDispatch(); @@ -40,8 +40,11 @@ const CarouselItem = React.forwardRef(( onPinned(avatar); } - onViewed(avatar.account_id); - markAsSeen.mutate(avatar.account_id); + if (!seen) { + onViewed(avatar.account_id); + markAsSeen.mutate(avatar.account_id); + } + dispatch(replaceHomeTimeline(avatar.account_id, { maxId: null }, () => setLoading(false))); } }; @@ -51,7 +54,7 @@ const CarouselItem = React.forwardRef(( ref={ref} aria-disabled={isFetching} onClick={handleClick} - className='cursor-pointer snap-start py-4' + className='cursor-pointer py-4' role='filter-feed-by-user' data-testid='carousel-item' > @@ -87,6 +90,7 @@ const FeedCarousel = () => { // eslint-disable-next-line @typescript-eslint/no-unused-vars const [_ref, setContainerRef, { width }] = useDimensions(); + const carouselItemRef = useRef(null); const [seenAccountIds, setSeenAccountIds] = useState([]); const [pageSize, setPageSize] = useState(0); @@ -151,18 +155,18 @@ const FeedCarousel = () => { data-testid='feed-carousel' > -
+
-
+
{pinnedAvatar ? (
{ seen={seenAccountIds?.includes(pinnedAvatar.account_id)} onViewed={markAsSeen} onPinned={(avatar) => setPinnedAvatar(avatar)} + ref={carouselItemRef} />
) : null} @@ -203,7 +208,11 @@ const FeedCarousel = () => { }} > {avatar === null ? ( - +
@@ -227,11 +236,11 @@ const FeedCarousel = () => {
-
+