Add videos tab to profile

This commit is contained in:
Eric Bailey
2025-01-20 17:02:59 -06:00
parent 99d23d65e2
commit 2a7bfb1e5d
3 changed files with 26 additions and 0 deletions
+2
View File
@@ -45,6 +45,7 @@ export const ProfileFeedSection = React.forwardRef<
const [hasNew, setHasNew] = React.useState(false) const [hasNew, setHasNew] = React.useState(false)
const [isScrolledDown, setIsScrolledDown] = React.useState(false) const [isScrolledDown, setIsScrolledDown] = React.useState(false)
const shouldUseAdjustedNumToRender = feed.endsWith('posts_and_author_threads') const shouldUseAdjustedNumToRender = feed.endsWith('posts_and_author_threads')
const isVideoFeed = isNative && feed.endsWith('posts_with_video')
const adjustedInitialNumToRender = useInitialNumToRender({ const adjustedInitialNumToRender = useInitialNumToRender({
screenHeightOffset: headerHeight, screenHeightOffset: headerHeight,
}) })
@@ -89,6 +90,7 @@ export const ProfileFeedSection = React.forwardRef<
initialNumToRender={ initialNumToRender={
shouldUseAdjustedNumToRender ? adjustedInitialNumToRender : undefined shouldUseAdjustedNumToRender ? adjustedInitialNumToRender : undefined
} }
isVideoFeed={isVideoFeed}
/> />
{(isScrolledDown || hasNew) && ( {(isScrolledDown || hasNew) && (
<LoadLatestBtn <LoadLatestBtn
+1
View File
@@ -49,6 +49,7 @@ export type AuthorFilter =
| 'posts_no_replies' | 'posts_no_replies'
| 'posts_and_author_threads' | 'posts_and_author_threads'
| 'posts_with_media' | 'posts_with_media'
| 'posts_with_video'
type FeedUri = string type FeedUri = string
type ListUri = string type ListUri = string
+23
View File
@@ -195,6 +195,7 @@ function ProfileScreenLoaded({
const postsSectionRef = React.useRef<SectionRef>(null) const postsSectionRef = React.useRef<SectionRef>(null)
const repliesSectionRef = React.useRef<SectionRef>(null) const repliesSectionRef = React.useRef<SectionRef>(null)
const mediaSectionRef = React.useRef<SectionRef>(null) const mediaSectionRef = React.useRef<SectionRef>(null)
const videosSectionRef = React.useRef<SectionRef>(null)
const likesSectionRef = React.useRef<SectionRef>(null) const likesSectionRef = React.useRef<SectionRef>(null)
const feedsSectionRef = React.useRef<SectionRef>(null) const feedsSectionRef = React.useRef<SectionRef>(null)
const listsSectionRef = React.useRef<SectionRef>(null) const listsSectionRef = React.useRef<SectionRef>(null)
@@ -218,6 +219,7 @@ function ProfileScreenLoaded({
const showPostsTab = true const showPostsTab = true
const showRepliesTab = hasSession const showRepliesTab = hasSession
const showMediaTab = !hasLabeler const showMediaTab = !hasLabeler
const showVideosTab = !hasLabeler
const showLikesTab = isMe const showLikesTab = isMe
const showFeedsTab = isMe || (profile.associated?.feedgens || 0) > 0 const showFeedsTab = isMe || (profile.associated?.feedgens || 0) > 0
const showStarterPacksTab = const showStarterPacksTab =
@@ -231,6 +233,7 @@ function ProfileScreenLoaded({
showPostsTab ? _(msg`Posts`) : undefined, showPostsTab ? _(msg`Posts`) : undefined,
showRepliesTab ? _(msg`Replies`) : undefined, showRepliesTab ? _(msg`Replies`) : undefined,
showMediaTab ? _(msg`Media`) : undefined, showMediaTab ? _(msg`Media`) : undefined,
showVideosTab ? _(msg`Videos`) : undefined,
showLikesTab ? _(msg`Likes`) : undefined, showLikesTab ? _(msg`Likes`) : undefined,
showFeedsTab ? _(msg`Feeds`) : undefined, showFeedsTab ? _(msg`Feeds`) : undefined,
showStarterPacksTab ? _(msg`Starter Packs`) : undefined, showStarterPacksTab ? _(msg`Starter Packs`) : undefined,
@@ -242,6 +245,7 @@ function ProfileScreenLoaded({
let postsIndex: number | null = null let postsIndex: number | null = null
let repliesIndex: number | null = null let repliesIndex: number | null = null
let mediaIndex: number | null = null let mediaIndex: number | null = null
let videosIndex: number | null = null
let likesIndex: number | null = null let likesIndex: number | null = null
let feedsIndex: number | null = null let feedsIndex: number | null = null
let starterPacksIndex: number | null = null let starterPacksIndex: number | null = null
@@ -258,6 +262,9 @@ function ProfileScreenLoaded({
if (showMediaTab) { if (showMediaTab) {
mediaIndex = nextIndex++ mediaIndex = nextIndex++
} }
if (showVideosTab) {
videosIndex = nextIndex++
}
if (showLikesTab) { if (showLikesTab) {
likesIndex = nextIndex++ likesIndex = nextIndex++
} }
@@ -281,6 +288,8 @@ function ProfileScreenLoaded({
repliesSectionRef.current?.scrollToTop() repliesSectionRef.current?.scrollToTop()
} else if (index === mediaIndex) { } else if (index === mediaIndex) {
mediaSectionRef.current?.scrollToTop() mediaSectionRef.current?.scrollToTop()
} else if (index === videosIndex) {
videosSectionRef.current?.scrollToTop()
} else if (index === likesIndex) { } else if (index === likesIndex) {
likesSectionRef.current?.scrollToTop() likesSectionRef.current?.scrollToTop()
} else if (index === feedsIndex) { } else if (index === feedsIndex) {
@@ -296,6 +305,7 @@ function ProfileScreenLoaded({
postsIndex, postsIndex,
repliesIndex, repliesIndex,
mediaIndex, mediaIndex,
videosIndex,
likesIndex, likesIndex,
feedsIndex, feedsIndex,
listsIndex, listsIndex,
@@ -435,6 +445,19 @@ function ProfileScreenLoaded({
/> />
) )
: null} : null}
{showVideosTab
? ({headerHeight, isFocused, scrollElRef}) => (
<ProfileFeedSection
ref={videosSectionRef}
feed={`author|${profile.did}|posts_with_video`}
headerHeight={headerHeight}
isFocused={isFocused}
scrollElRef={scrollElRef as ListRef}
ignoreFilterFor={profile.did}
setScrollViewTag={setScrollViewTag}
/>
)
: null}
{showLikesTab {showLikesTab
? ({headerHeight, isFocused, scrollElRef}) => ( ? ({headerHeight, isFocused, scrollElRef}) => (
<ProfileFeedSection <ProfileFeedSection