More profile refactor updates (#1886)
* Update the profile avatar lightbox * Update profile editor * Add dynamic likes tab * Add dynamic feeds and lists tabs * Implement lists listing on profiles
This commit is contained in:
parent
8217761363
commit
a01463788d
14 changed files with 432 additions and 84 deletions
|
@ -5,7 +5,7 @@ import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
|||
import {AtUri} from '@atproto/api'
|
||||
import {NativeStackScreenProps, CommonNavigatorParams} from 'lib/routes/types'
|
||||
import {withAuthRequired} from 'view/com/auth/withAuthRequired'
|
||||
import {ListsList} from 'view/com/lists/ListsList'
|
||||
import {MyLists} from '#/view/com/lists/MyLists'
|
||||
import {Text} from 'view/com/util/text/Text'
|
||||
import {Button} from 'view/com/util/forms/Button'
|
||||
import {NavigationProp} from 'lib/routes/types'
|
||||
|
@ -79,7 +79,7 @@ export const ListsScreen = withAuthRequired(
|
|||
</Button>
|
||||
</View>
|
||||
</SimpleViewHeader>
|
||||
<ListsList filter="curate" style={s.flexGrow1} />
|
||||
<MyLists filter="curate" style={s.flexGrow1} />
|
||||
</View>
|
||||
)
|
||||
},
|
||||
|
|
|
@ -5,7 +5,7 @@ import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
|||
import {AtUri} from '@atproto/api'
|
||||
import {NativeStackScreenProps, CommonNavigatorParams} from 'lib/routes/types'
|
||||
import {withAuthRequired} from 'view/com/auth/withAuthRequired'
|
||||
import {ListsList} from 'view/com/lists/ListsList'
|
||||
import {MyLists} from '#/view/com/lists/MyLists'
|
||||
import {Text} from 'view/com/util/text/Text'
|
||||
import {Button} from 'view/com/util/forms/Button'
|
||||
import {NavigationProp} from 'lib/routes/types'
|
||||
|
@ -79,7 +79,7 @@ export const ModerationModlistsScreen = withAuthRequired(
|
|||
</Button>
|
||||
</View>
|
||||
</SimpleViewHeader>
|
||||
<ListsList filter="mod" style={s.flexGrow1} />
|
||||
<MyLists filter="mod" style={s.flexGrow1} />
|
||||
</View>
|
||||
)
|
||||
},
|
||||
|
|
|
@ -10,6 +10,7 @@ import {ViewSelectorHandle} from '../com/util/ViewSelector'
|
|||
import {CenteredView} from '../com/util/Views'
|
||||
import {ScreenHider} from 'view/com/util/moderation/ScreenHider'
|
||||
import {Feed} from 'view/com/posts/Feed'
|
||||
import {ProfileLists} from '../com/lists/ProfileLists'
|
||||
import {useStores} from 'state/index'
|
||||
import {ProfileHeader} from '../com/profile/ProfileHeader'
|
||||
import {PagerWithHeader} from 'view/com/pager/PagerWithHeader'
|
||||
|
@ -28,11 +29,10 @@ import {useProfileQuery} from '#/state/queries/profile'
|
|||
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
||||
import {useSession} from '#/state/session'
|
||||
import {useModerationOpts} from '#/state/queries/preferences'
|
||||
import {useProfileExtraInfoQuery} from '#/state/queries/profile-extra-info'
|
||||
import {useSetDrawerSwipeDisabled, useSetMinimalShellMode} from '#/state/shell'
|
||||
import {cleanError} from '#/lib/strings/errors'
|
||||
|
||||
const SECTION_TITLES_PROFILE = ['Posts', 'Posts & Replies', 'Media', 'Likes']
|
||||
|
||||
type Props = NativeStackScreenProps<CommonNavigatorParams, 'Profile'>
|
||||
export const ProfileScreen = withAuthRequired(function ProfileScreenImpl({
|
||||
route,
|
||||
|
@ -129,6 +129,7 @@ function ProfileScreenLoaded({
|
|||
const {_} = useLingui()
|
||||
const viewSelectorRef = React.useRef<ViewSelectorHandle>(null)
|
||||
const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled()
|
||||
const extraInfoQuery = useProfileExtraInfoQuery(profile.did)
|
||||
|
||||
useSetTitle(combinedDisplayName(profile))
|
||||
|
||||
|
@ -137,6 +138,21 @@ function ProfileScreenLoaded({
|
|||
[profile, moderationOpts],
|
||||
)
|
||||
|
||||
const isMe = profile.did === currentAccount?.did
|
||||
const showLikesTab = isMe
|
||||
const showFeedsTab = isMe || extraInfoQuery.data?.hasFeeds
|
||||
const showListsTab = isMe || extraInfoQuery.data?.hasLists
|
||||
const sectionTitles = useMemo<string[]>(() => {
|
||||
return [
|
||||
'Posts',
|
||||
'Posts & Replies',
|
||||
'Media',
|
||||
showLikesTab ? 'Likes' : undefined,
|
||||
showFeedsTab ? 'Feeds' : undefined,
|
||||
showListsTab ? 'Lists' : undefined,
|
||||
].filter(Boolean) as string[]
|
||||
}, [showLikesTab, showFeedsTab, showListsTab])
|
||||
|
||||
/*
|
||||
- todo
|
||||
- feeds
|
||||
|
@ -204,7 +220,7 @@ function ProfileScreenLoaded({
|
|||
moderation={moderation.account}>
|
||||
<PagerWithHeader
|
||||
isHeaderReady={true}
|
||||
items={SECTION_TITLES_PROFILE}
|
||||
items={sectionTitles}
|
||||
onPageSelected={onPageSelected}
|
||||
renderHeader={renderHeader}>
|
||||
{({onScroll, headerHeight, isScrolledDown, scrollElRef}) => (
|
||||
|
@ -237,16 +253,40 @@ function ProfileScreenLoaded({
|
|||
scrollElRef={scrollElRef}
|
||||
/>
|
||||
)}
|
||||
{({onScroll, headerHeight, isScrolledDown, scrollElRef}) => (
|
||||
<FeedSection
|
||||
ref={null}
|
||||
feed={`likes|${profile.did}`}
|
||||
onScroll={onScroll}
|
||||
headerHeight={headerHeight}
|
||||
isScrolledDown={isScrolledDown}
|
||||
scrollElRef={scrollElRef}
|
||||
/>
|
||||
)}
|
||||
{showLikesTab
|
||||
? ({onScroll, headerHeight, isScrolledDown, scrollElRef}) => (
|
||||
<FeedSection
|
||||
ref={null}
|
||||
feed={`likes|${profile.did}`}
|
||||
onScroll={onScroll}
|
||||
headerHeight={headerHeight}
|
||||
isScrolledDown={isScrolledDown}
|
||||
scrollElRef={scrollElRef}
|
||||
/>
|
||||
)
|
||||
: null}
|
||||
{showFeedsTab
|
||||
? ({onScroll, headerHeight, scrollElRef}) => (
|
||||
<ProfileLists // TODO put feeds here, using this temporarily to avoid bugs
|
||||
did={profile.did}
|
||||
scrollElRef={scrollElRef}
|
||||
onScroll={onScroll}
|
||||
scrollEventThrottle={1}
|
||||
headerOffset={headerHeight}
|
||||
/>
|
||||
)
|
||||
: null}
|
||||
{showListsTab
|
||||
? ({onScroll, headerHeight, scrollElRef}) => (
|
||||
<ProfileLists
|
||||
did={profile.did}
|
||||
scrollElRef={scrollElRef}
|
||||
onScroll={onScroll}
|
||||
scrollEventThrottle={1}
|
||||
headerOffset={headerHeight}
|
||||
/>
|
||||
)
|
||||
: null}
|
||||
</PagerWithHeader>
|
||||
<FAB
|
||||
testID="composeFAB"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue