From 6538013484a42a3b92001725ec2602dab86eb939 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 21 Jan 2025 18:45:33 -0600 Subject: [PATCH] Add videos tab to profile (#7517) * Add videos tab to profile * Modify sourceContext for author feeds * Use actual typecast, better name for feedUri * Make EOF conditional * Clearer condition --------- Co-authored-by: Dan Abramov --- src/screens/Profile/Sections/Feed.tsx | 4 ++- src/state/queries/post-feed.ts | 1 + src/view/com/posts/PostFeed.tsx | 39 ++++++++++++++++++--------- src/view/screens/Profile.tsx | 23 ++++++++++++++++ 4 files changed, 54 insertions(+), 13 deletions(-) diff --git a/src/screens/Profile/Sections/Feed.tsx b/src/screens/Profile/Sections/Feed.tsx index 0ad197f5f2..3e3fe973e6 100644 --- a/src/screens/Profile/Sections/Feed.tsx +++ b/src/screens/Profile/Sections/Feed.tsx @@ -45,6 +45,7 @@ export const ProfileFeedSection = React.forwardRef< const [hasNew, setHasNew] = React.useState(false) const [isScrolledDown, setIsScrolledDown] = React.useState(false) const shouldUseAdjustedNumToRender = feed.endsWith('posts_and_author_threads') + const isVideoFeed = isNative && feed.endsWith('posts_with_video') const adjustedInitialNumToRender = useInitialNumToRender({ screenHeightOffset: headerHeight, }) @@ -84,11 +85,12 @@ export const ProfileFeedSection = React.forwardRef< renderEmptyState={renderPostsEmpty} headerOffset={headerHeight} progressViewOffset={ios(0)} - renderEndOfFeed={ProfileEndOfFeed} + renderEndOfFeed={isVideoFeed ? undefined : ProfileEndOfFeed} ignoreFilterFor={ignoreFilterFor} initialNumToRender={ shouldUseAdjustedNumToRender ? adjustedInitialNumToRender : undefined } + isVideoFeed={isVideoFeed} /> {(isScrolledDown || hasNew) && ( void) | null>(null) const lastFetchRef = React.useRef(Date.now()) - const [feedType, feedUri, feedTab] = feed.split('|') + const [feedType, feedUriOrActorDid, feedTab] = feed.split('|') const {gtMobile, gtTablet} = useBreakpoints() const areVideoFeedsEnabled = isNative @@ -307,7 +309,7 @@ let PostFeed = ({ let feedKind: 'following' | 'discover' | 'profile' | 'thevids' | undefined if (feedType === 'following') { feedKind = 'following' - } else if (feedUri === DISCOVER_FEED_URI) { + } else if (feedUriOrActorDid === DISCOVER_FEED_URI) { feedKind = 'discover' } else if ( feedType === 'author' && @@ -318,7 +320,7 @@ let PostFeed = ({ } let arr: FeedRow[] = [] - if (KNOWN_SHUTDOWN_FEEDS.includes(feedUri)) { + if (KNOWN_SHUTDOWN_FEEDS.includes(feedUriOrActorDid)) { arr.push({ type: 'feedShutdownMsg', key: 'feedShutdownMsg', @@ -376,7 +378,7 @@ let PostFeed = ({ type: 'videoGridRow', key: row.map(r => r.item._reactKey).join('-'), items: row.map(r => r.item), - sourceFeedUri: feedUri, + sourceFeedUri: feedUriOrActorDid, feedContexts: row.map(r => r.feedContext), }) } @@ -504,7 +506,7 @@ let PostFeed = ({ lastFetchedAt, data, feedType, - feedUri, + feedUriOrActorDid, feedTab, hasSession, showProgressIntersitial, @@ -595,7 +597,7 @@ let PostFeed = ({ } else if (row.type === 'loading') { return } else if (row.type === 'feedShutdownMsg') { - return + return } else if (row.type === 'interstitialFollows') { return } else if (row.type === 'interstitialProgressGuide') { @@ -646,14 +648,25 @@ let PostFeed = ({ ) } else if (row.type === 'videoGridRow') { + let sourceContext: VideoFeedSourceContext + if (feedType === 'author') { + sourceContext = { + type: 'author', + did: feedUriOrActorDid, + filter: feedTab as AuthorFilter, + } + } else { + sourceContext = { + type: 'feedgen', + uri: row.sourceFeedUri, + sourceInterstitial: feedCacheKey ?? 'none', + } + } + return ( ) } else { @@ -668,7 +681,9 @@ let PostFeed = ({ savedFeedConfig, _, onPressRetryLoadMore, - feedUri, + feedType, + feedUriOrActorDid, + feedTab, feedCacheKey, ], ) diff --git a/src/view/screens/Profile.tsx b/src/view/screens/Profile.tsx index 24e8719e17..4e0ac259f0 100644 --- a/src/view/screens/Profile.tsx +++ b/src/view/screens/Profile.tsx @@ -195,6 +195,7 @@ function ProfileScreenLoaded({ const postsSectionRef = React.useRef(null) const repliesSectionRef = React.useRef(null) const mediaSectionRef = React.useRef(null) + const videosSectionRef = React.useRef(null) const likesSectionRef = React.useRef(null) const feedsSectionRef = React.useRef(null) const listsSectionRef = React.useRef(null) @@ -218,6 +219,7 @@ function ProfileScreenLoaded({ const showPostsTab = true const showRepliesTab = hasSession const showMediaTab = !hasLabeler + const showVideosTab = !hasLabeler const showLikesTab = isMe const showFeedsTab = isMe || (profile.associated?.feedgens || 0) > 0 const showStarterPacksTab = @@ -231,6 +233,7 @@ function ProfileScreenLoaded({ showPostsTab ? _(msg`Posts`) : undefined, showRepliesTab ? _(msg`Replies`) : undefined, showMediaTab ? _(msg`Media`) : undefined, + showVideosTab ? _(msg`Videos`) : undefined, showLikesTab ? _(msg`Likes`) : undefined, showFeedsTab ? _(msg`Feeds`) : undefined, showStarterPacksTab ? _(msg`Starter Packs`) : undefined, @@ -242,6 +245,7 @@ function ProfileScreenLoaded({ let postsIndex: number | null = null let repliesIndex: number | null = null let mediaIndex: number | null = null + let videosIndex: number | null = null let likesIndex: number | null = null let feedsIndex: number | null = null let starterPacksIndex: number | null = null @@ -258,6 +262,9 @@ function ProfileScreenLoaded({ if (showMediaTab) { mediaIndex = nextIndex++ } + if (showVideosTab) { + videosIndex = nextIndex++ + } if (showLikesTab) { likesIndex = nextIndex++ } @@ -281,6 +288,8 @@ function ProfileScreenLoaded({ repliesSectionRef.current?.scrollToTop() } else if (index === mediaIndex) { mediaSectionRef.current?.scrollToTop() + } else if (index === videosIndex) { + videosSectionRef.current?.scrollToTop() } else if (index === likesIndex) { likesSectionRef.current?.scrollToTop() } else if (index === feedsIndex) { @@ -296,6 +305,7 @@ function ProfileScreenLoaded({ postsIndex, repliesIndex, mediaIndex, + videosIndex, likesIndex, feedsIndex, listsIndex, @@ -435,6 +445,19 @@ function ProfileScreenLoaded({ /> ) : null} + {showVideosTab + ? ({headerHeight, isFocused, scrollElRef}) => ( + + ) + : null} {showLikesTab ? ({headerHeight, isFocused, scrollElRef}) => (