fix race when adding pinned feed
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import {View} from 'react-native'
|
||||
import {AppBskyGraphDefs, AppBskyGraphStarterpack, AtUri} from '@atproto/api'
|
||||
import {AppBskyGraphDefs, AppBskyGraphStarterpack} from '@atproto/api'
|
||||
import {msg, Trans} from '@lingui/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {useQueryClient} from '@tanstack/react-query'
|
||||
@@ -78,20 +78,18 @@ export function StepFinished() {
|
||||
...(listItems?.map(i => i.subject.did) ?? []),
|
||||
]),
|
||||
(async () => {
|
||||
await agent.setInterestsPref({tags: selectedInterests})
|
||||
|
||||
if (starterPack?.feeds?.length) {
|
||||
await agent.addSavedFeeds(
|
||||
starterPack.feeds.map(f => ({
|
||||
type: 'feed',
|
||||
value: f.uri,
|
||||
pinned: true,
|
||||
id: new AtUri(f.uri).rkey,
|
||||
})),
|
||||
)
|
||||
}
|
||||
})(),
|
||||
(async () => {
|
||||
await agent.setInterestsPref({tags: selectedInterests})
|
||||
})(),
|
||||
(async () => {
|
||||
const {imageUri, imageMime} = profileStepResults
|
||||
if (imageUri && imageMime) {
|
||||
|
||||
@@ -9,9 +9,12 @@ import {
|
||||
import {msg, Trans} from '@lingui/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {useNavigation} from '@react-navigation/native'
|
||||
import {NativeStackScreenProps} from '@react-navigation/native-stack'
|
||||
|
||||
import {NavigationProp} from 'lib/routes/types'
|
||||
import {CommonNavigatorParams, NavigationProp} from 'lib/routes/types'
|
||||
import {useSetUsedStarterPack} from 'state/preferences/starter-pack'
|
||||
import {useResolveDidQuery} from 'state/queries/resolve-uri'
|
||||
import {useStarterPackQuery} from 'state/queries/useStarterPackQuery'
|
||||
import {useSession} from 'state/session'
|
||||
import {useSetMinimalShellMode} from 'state/shell'
|
||||
import {useLoggedOutViewControls} from 'state/shell/logged-out'
|
||||
@@ -22,125 +25,128 @@ import {Logo} from 'view/icons/Logo'
|
||||
import {atoms as a, useTheme} from '#/alf'
|
||||
import {Button, ButtonText} from '#/components/Button'
|
||||
import {Divider} from '#/components/Divider'
|
||||
import {ListMaybePlaceholder} from '#/components/Lists'
|
||||
import {Text} from '#/components/Typography'
|
||||
|
||||
const mockSP = {
|
||||
uri: 'at://did:plc:t5nrviyjxkdhd5ymyra772dm/app.bsky.graph.starterpack/3kuec35ms422t',
|
||||
cid: 'bafyreigrvmj3qd4urr5q6lqku7uzj4xmazepik6oobuxtvunx3g7d6e6xi',
|
||||
record: {
|
||||
list: 'at://did:plc:t5nrviyjxkdhd5ymyra772dm/app.bsky.graph.list/3kuec35kvkj2t',
|
||||
name: 'Bluesky Team',
|
||||
$type: 'app.bsky.graph.starterpack',
|
||||
feeds: [
|
||||
{
|
||||
uri: 'at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/bsky-team',
|
||||
},
|
||||
{
|
||||
uri: 'at://did:plc:oio4hkxaop4ao4wz2pp3f4cr/app.bsky.feed.generator/atproto',
|
||||
},
|
||||
],
|
||||
createdAt: '2024-06-07T19:43:07.211Z',
|
||||
description:
|
||||
'A starter pack including all the members of the Bluesky Team!',
|
||||
descriptionFacets: [],
|
||||
},
|
||||
creator: {
|
||||
did: 'did:plc:t5nrviyjxkdhd5ymyra772dm',
|
||||
handle: 'haileyok.com',
|
||||
displayName: 'hailey',
|
||||
associated: {
|
||||
chat: {
|
||||
allowIncoming: 'following',
|
||||
},
|
||||
},
|
||||
viewer: {
|
||||
muted: false,
|
||||
blockedBy: false,
|
||||
},
|
||||
labels: [],
|
||||
},
|
||||
feedCount: 0,
|
||||
joinedAllTimeCount: 302,
|
||||
joinedWeekCount: 143,
|
||||
listItemCount: 2,
|
||||
labels: [],
|
||||
indexedAt: '2024-06-07T19:43:07.211Z',
|
||||
feeds: [],
|
||||
list: {
|
||||
uri: 'at://did:plc:oisofpd7lj26yvgiivf3lxsi/app.bsky.graph.list/3kuc6z2xxd22j',
|
||||
cid: 'bafyreibnigtususbzhjzadhsqconcf7s5wan6dl7h6s56jhxd6ebfvflrq',
|
||||
name: 'Bluesky Team',
|
||||
purpose: 'app.bsky.graph.defs#referencelist',
|
||||
indexedAt: '2024-06-07T19:43:07.122Z',
|
||||
labels: [],
|
||||
viewer: {
|
||||
muted: false,
|
||||
},
|
||||
},
|
||||
listItemsSample: [
|
||||
{
|
||||
uri: 'at://did:plc:t5nrviyjxkdhd5ymyra772dm/app.bsky.graph.listitem/3kuec35m2o22t',
|
||||
subject: {
|
||||
did: 'did:plc:5warwwnoavxfhchjhcjlqyqi',
|
||||
handle: 'bob.test',
|
||||
displayName: 'Bob',
|
||||
viewer: {
|
||||
muted: false,
|
||||
blockedBy: false,
|
||||
following:
|
||||
'at://did:plc:t5nrviyjxkdhd5ymyra772dm/app.bsky.graph.follow/3kudwno6ck22t',
|
||||
followedBy:
|
||||
'at://did:plc:5warwwnoavxfhchjhcjlqyqi/app.bsky.graph.follow/3kudwno6nbs2t',
|
||||
},
|
||||
labels: [],
|
||||
description: 'Test user 2',
|
||||
indexedAt: '2024-06-07T16:18:43.414Z',
|
||||
},
|
||||
},
|
||||
{
|
||||
uri: 'at://did:plc:t5nrviyjxkdhd5ymyra772dm/app.bsky.graph.listitem/3kuec35m2nz2t',
|
||||
subject: {
|
||||
did: 'did:plc:cvdwnci2mr5srh4slty7lndz',
|
||||
handle: 'carla.test',
|
||||
displayName: 'Carla',
|
||||
viewer: {
|
||||
muted: false,
|
||||
blockedBy: false,
|
||||
following:
|
||||
'at://did:plc:t5nrviyjxkdhd5ymyra772dm/app.bsky.graph.follow/3kudwno6hgc2t',
|
||||
followedBy:
|
||||
'at://did:plc:cvdwnci2mr5srh4slty7lndz/app.bsky.graph.follow/3kudwno6x2c2t',
|
||||
},
|
||||
labels: [],
|
||||
description: 'Test user 3',
|
||||
indexedAt: '2024-06-07T16:18:43.462Z',
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
// const mockSP = {
|
||||
// uri: 'at://did:plc:t5nrviyjxkdhd5ymyra772dm/app.bsky.graph.starterpack/3kuec35ms422t',
|
||||
// cid: 'bafyreigrvmj3qd4urr5q6lqku7uzj4xmazepik6oobuxtvunx3g7d6e6xi',
|
||||
// record: {
|
||||
// list: 'at://did:plc:t5nrviyjxkdhd5ymyra772dm/app.bsky.graph.list/3kuec35kvkj2t',
|
||||
// name: 'Bluesky Team',
|
||||
// $type: 'app.bsky.graph.starterpack',
|
||||
// feeds: [
|
||||
// {
|
||||
// uri: 'at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/bsky-team',
|
||||
// },
|
||||
// {
|
||||
// uri: 'at://did:plc:oio4hkxaop4ao4wz2pp3f4cr/app.bsky.feed.generator/atproto',
|
||||
// },
|
||||
// ],
|
||||
// createdAt: '2024-06-07T19:43:07.211Z',
|
||||
// description:
|
||||
// 'A starter pack including all the members of the Bluesky Team!',
|
||||
// descriptionFacets: [],
|
||||
// },
|
||||
// creator: {
|
||||
// did: 'did:plc:t5nrviyjxkdhd5ymyra772dm',
|
||||
// handle: 'haileyok.com',
|
||||
// displayName: 'hailey',
|
||||
// associated: {
|
||||
// chat: {
|
||||
// allowIncoming: 'following',
|
||||
// },
|
||||
// },
|
||||
// viewer: {
|
||||
// muted: false,
|
||||
// blockedBy: false,
|
||||
// },
|
||||
// labels: [],
|
||||
// },
|
||||
// feedCount: 0,
|
||||
// joinedAllTimeCount: 302,
|
||||
// joinedWeekCount: 143,
|
||||
// listItemCount: 2,
|
||||
// labels: [],
|
||||
// indexedAt: '2024-06-07T19:43:07.211Z',
|
||||
// feeds: [],
|
||||
// list: {
|
||||
// uri: 'at://did:plc:oisofpd7lj26yvgiivf3lxsi/app.bsky.graph.list/3kuc6z2xxd22j',
|
||||
// cid: 'bafyreibnigtususbzhjzadhsqconcf7s5wan6dl7h6s56jhxd6ebfvflrq',
|
||||
// name: 'Bluesky Team',
|
||||
// purpose: 'app.bsky.graph.defs#referencelist',
|
||||
// indexedAt: '2024-06-07T19:43:07.122Z',
|
||||
// labels: [],
|
||||
// viewer: {
|
||||
// muted: false,
|
||||
// },
|
||||
// },
|
||||
// listItemsSample: [
|
||||
// {
|
||||
// uri: 'at://did:plc:t5nrviyjxkdhd5ymyra772dm/app.bsky.graph.listitem/3kuec35m2o22t',
|
||||
// subject: {
|
||||
// did: 'did:plc:5warwwnoavxfhchjhcjlqyqi',
|
||||
// handle: 'bob.test',
|
||||
// displayName: 'Bob',
|
||||
// viewer: {
|
||||
// muted: false,
|
||||
// blockedBy: false,
|
||||
// following:
|
||||
// 'at://did:plc:t5nrviyjxkdhd5ymyra772dm/app.bsky.graph.follow/3kudwno6ck22t',
|
||||
// followedBy:
|
||||
// 'at://did:plc:5warwwnoavxfhchjhcjlqyqi/app.bsky.graph.follow/3kudwno6nbs2t',
|
||||
// },
|
||||
// labels: [],
|
||||
// description: 'Test user 2',
|
||||
// indexedAt: '2024-06-07T16:18:43.414Z',
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// uri: 'at://did:plc:t5nrviyjxkdhd5ymyra772dm/app.bsky.graph.listitem/3kuec35m2nz2t',
|
||||
// subject: {
|
||||
// did: 'did:plc:cvdwnci2mr5srh4slty7lndz',
|
||||
// handle: 'carla.test',
|
||||
// displayName: 'Carla',
|
||||
// viewer: {
|
||||
// muted: false,
|
||||
// blockedBy: false,
|
||||
// following:
|
||||
// 'at://did:plc:t5nrviyjxkdhd5ymyra772dm/app.bsky.graph.follow/3kudwno6hgc2t',
|
||||
// followedBy:
|
||||
// 'at://did:plc:cvdwnci2mr5srh4slty7lndz/app.bsky.graph.follow/3kudwno6x2c2t',
|
||||
// },
|
||||
// labels: [],
|
||||
// description: 'Test user 3',
|
||||
// indexedAt: '2024-06-07T16:18:43.462Z',
|
||||
// },
|
||||
// },
|
||||
// ],
|
||||
// }
|
||||
|
||||
export function LandingScreen({}) {
|
||||
// const {name, rkey} = route.params
|
||||
export function LandingScreen({
|
||||
route,
|
||||
}: NativeStackScreenProps<CommonNavigatorParams, 'StarterPackLanding'>) {
|
||||
const {name, rkey} = route.params
|
||||
const navigation = useNavigation<NavigationProp>()
|
||||
const {currentAccount} = useSession()
|
||||
const setMinimalShellMode = useSetMinimalShellMode()
|
||||
|
||||
// const {
|
||||
// data: did,
|
||||
// isLoading: isLoadingDid,
|
||||
// isError: isErrorDid,
|
||||
// } = useResolveDidQuery(name)
|
||||
// const {
|
||||
// data: starterPack,
|
||||
// isLoading: isLoadingStarterPack,
|
||||
// isError: isErrorStarterPack,
|
||||
// } = useStarterPackQuery({did, rkey})
|
||||
const {
|
||||
data: did,
|
||||
isLoading: isLoadingDid,
|
||||
isError: isErrorDid,
|
||||
} = useResolveDidQuery(name)
|
||||
const {
|
||||
data: starterPack,
|
||||
isLoading: isLoadingStarterPack,
|
||||
isError: isErrorStarterPack,
|
||||
} = useStarterPackQuery({did, rkey})
|
||||
|
||||
React.useEffect(() => {
|
||||
if (currentAccount) {
|
||||
navigation.navigate('Home')
|
||||
return
|
||||
}
|
||||
// if (currentAccount) {
|
||||
// navigation.navigate('Home')
|
||||
// return
|
||||
// }
|
||||
|
||||
setMinimalShellMode(true)
|
||||
return () => {
|
||||
@@ -148,16 +154,16 @@ export function LandingScreen({}) {
|
||||
}
|
||||
}, [currentAccount, navigation, setMinimalShellMode])
|
||||
|
||||
// if (!did || !starterPack) {
|
||||
// return (
|
||||
// <ListMaybePlaceholder
|
||||
// isLoading={isLoadingDid || isLoadingStarterPack}
|
||||
// isError={isErrorDid || isErrorStarterPack}
|
||||
// />
|
||||
// )
|
||||
// }
|
||||
if (!did || !starterPack) {
|
||||
return (
|
||||
<ListMaybePlaceholder
|
||||
isLoading={isLoadingDid || isLoadingStarterPack}
|
||||
isError={isErrorDid || isErrorStarterPack}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return <LandingScreenInner starterPack={mockSP} />
|
||||
return <LandingScreenInner starterPack={starterPack} />
|
||||
}
|
||||
|
||||
function LandingScreenInner({
|
||||
@@ -234,20 +240,24 @@ function LandingScreenInner({
|
||||
{record.description}
|
||||
</Text>
|
||||
<Divider />
|
||||
<>
|
||||
<Text />
|
||||
{starterPack.feeds?.length && (
|
||||
<View
|
||||
style={[
|
||||
t.atoms.bg_contrast_25,
|
||||
a.rounded_sm,
|
||||
{pointerEvents: 'none'},
|
||||
]}>
|
||||
<FeedSourceCard
|
||||
feedUri="at://did:plc:jfhpnnst6flqway4eaeqzj2a/app.bsky.feed.generator/for-science"
|
||||
hideTopBorder={true}
|
||||
/>
|
||||
<FeedSourceCard feedUri="at://did:plc:upmfcx5muayjhkg5sltj625o/app.bsky.feed.generator/aaachrckxlsh2" />
|
||||
{starterPack.feeds?.map(feed => (
|
||||
<FeedSourceCard key={feed.uri} feedUri={feed.uri} />
|
||||
))}
|
||||
{/*<FeedSourceCard*/}
|
||||
{/* feedUri="at://did:plc:jfhpnnst6flqway4eaeqzj2a/app.bsky.feed.generator/for-science"*/}
|
||||
{/* hideTopBorder={true}*/}
|
||||
{/*/>*/}
|
||||
{/*<FeedSourceCard feedUri="at://did:plc:upmfcx5muayjhkg5sltj625o/app.bsky.feed.generator/aaachrckxlsh2" />*/}
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
|
||||
{sampleProfiles?.length && (
|
||||
<>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React, {useCallback} from 'react'
|
||||
import {View} from 'react-native'
|
||||
import {AppBskyFeedDefs} from '@atproto/api'
|
||||
|
||||
import {useBottomBarOffset} from 'lib/hooks/useBottomBarOffset'
|
||||
import {isNative} from 'platform/detection'
|
||||
@@ -7,16 +8,16 @@ import {FeedSourceCard} from 'view/com/feeds/FeedSourceCard'
|
||||
import {List, ListRef} from 'view/com/util/List'
|
||||
import {SectionRef} from '#/screens/Profile/Sections/types'
|
||||
|
||||
function renderItem({item}: {item: string}) {
|
||||
return <FeedSourceCard feedUri={item} />
|
||||
function renderItem({item}: {item: AppBskyFeedDefs.GeneratorView}) {
|
||||
return <FeedSourceCard feedUri={item.uri} />
|
||||
}
|
||||
|
||||
function keyExtractor(item: string) {
|
||||
return item
|
||||
function keyExtractor(item: AppBskyFeedDefs.GeneratorView) {
|
||||
return item.uri
|
||||
}
|
||||
|
||||
interface ProfilesListProps {
|
||||
feeds: string[]
|
||||
feeds: AppBskyFeedDefs.GeneratorView[]
|
||||
headerHeight: number
|
||||
scrollElRef: ListRef
|
||||
}
|
||||
|
||||
@@ -26,9 +26,38 @@ export function StepFeeds() {
|
||||
const [query, setQuery] = useState('')
|
||||
|
||||
const {data: popularFeedsPages, fetchNextPage} = useGetPopularFeedsQuery(30)
|
||||
// const popularFeeds =
|
||||
// popularFeedsPages?.pages.flatMap(page => page.feeds) || []
|
||||
|
||||
const popularFeeds =
|
||||
popularFeedsPages?.pages.flatMap(page => page.feeds) || []
|
||||
const popularFeeds = [
|
||||
{
|
||||
uri: 'at://did:plc:6262fucmqlkgz23yaslhuuq6/app.bsky.feed.generator/alice-favs',
|
||||
cid: 'bafyreidgvy4vlvvhx3lhpyej2qido3m5sk2l5643bhbmqtgfuxwz53xqlm',
|
||||
did: 'did:plc:epfqsozl6rso6ebd6mkfyzpl',
|
||||
creator: {
|
||||
did: 'did:plc:vyhhvdf4xw5nziakfxxsynwk',
|
||||
handle: 'alice.test',
|
||||
displayName: 'Alice',
|
||||
viewer: {
|
||||
muted: false,
|
||||
blockedBy: false,
|
||||
},
|
||||
labels: [],
|
||||
description: 'Test user 1',
|
||||
indexedAt: '2024-06-10T17:37:36.662Z',
|
||||
},
|
||||
displayName: 'alices feed',
|
||||
description: 'all my fav stuff',
|
||||
avatar:
|
||||
'http://localhost:2584/img/avatar/plain/did:plc:vyhhvdf4xw5nziakfxxsynwk/bafkreihem6nzbu462kcx5cqnrkonpq75fe5dlbhgnzcmuvvhqk7s5vcq3u@jpeg',
|
||||
likeCount: 3,
|
||||
labels: [],
|
||||
viewer: {
|
||||
like: 'at://did:plc:vyhhvdf4xw5nziakfxxsynwk/app.bsky.feed.like/3kulmhjxuoc2g',
|
||||
},
|
||||
indexedAt: '2022-07-15T00:51:16.914Z',
|
||||
},
|
||||
]
|
||||
|
||||
const {
|
||||
data: searchedFeeds,
|
||||
|
||||
Reference in New Issue
Block a user