do the same on starter pack screen

This commit is contained in:
Hailey
2024-06-11 13:58:29 -07:00
parent 3fe9354ece
commit 28b47c0e0e
+14 -1
View File
@@ -5,6 +5,7 @@ import {AppBskyActorDefs} from '@atproto/api'
import {useBottomBarOffset} from 'lib/hooks/useBottomBarOffset'
import {isNative} from 'platform/detection'
import {useListMembersQuery} from 'state/queries/list-members'
import {useSession} from 'state/session'
import {ProfileCardWithFollowBtn} from 'view/com/profile/ProfileCard'
import {List, ListRef} from 'view/com/util/List'
import {SectionRef} from '#/screens/Profile/Sections/types'
@@ -32,10 +33,22 @@ export const ProfilesList = React.forwardRef<SectionRef, ProfilesListProps>(
function ProfilesListImpl({listUri, headerHeight, scrollElRef}, ref) {
const [initialHeaderHeight] = React.useState(headerHeight)
const bottomBarOffset = useBottomBarOffset(20)
const {currentAccount} = useSession()
const {data} = useListMembersQuery(listUri)
const profiles = data?.pages.flatMap(p => p.items.map(i => i.subject))
const getSortedProfiles = () => {
if (!profiles) return
const myIndex = profiles.findIndex(p => p.did === currentAccount?.did)
return [
profiles[myIndex],
...profiles.slice(0, myIndex),
...profiles.slice(myIndex + 1),
]
}
const onScrollToTop = useCallback(() => {
scrollElRef.current?.scrollToOffset({
animated: isNative,
@@ -49,7 +62,7 @@ export const ProfilesList = React.forwardRef<SectionRef, ProfilesListProps>(
return (
<List
data={profiles}
data={getSortedProfiles()}
renderItem={renderItem}
keyExtractor={keyExtractor}
ref={scrollElRef}