Skip to content

Commit b04db22

Browse files
committed
use new API
1 parent 991e990 commit b04db22

File tree

4 files changed

+1285
-1212
lines changed

4 files changed

+1285
-1212
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"icons:optimize": "svgo -f ./assets/icons"
7272
},
7373
"dependencies": {
74-
"@atproto/api": "^0.16.7",
74+
"@atproto/api": "^0.16.11",
7575
"@bitdrift/react-native": "^0.6.8",
7676
"@braintree/sanitize-url": "^6.0.2",
7777
"@bsky.app/alf": "^0.1.2",
@@ -220,7 +220,7 @@
220220
"zod": "^3.20.2"
221221
},
222222
"devDependencies": {
223-
"@atproto/dev-env": "^0.3.172",
223+
"@atproto/dev-env": "^0.3.179",
224224
"@babel/core": "^7.26.0",
225225
"@babel/preset-env": "^7.26.0",
226226
"@babel/runtime": "^7.26.0",

src/screens/Onboarding/StepSuggestedStarterpacks/index.tsx

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {msg, Trans} from '@lingui/macro'
44
import {useLingui} from '@lingui/react'
55

66
import {useModerationOpts} from '#/state/preferences/moderation-opts'
7-
import {useSuggestedStarterPacksQuery} from '#/state/queries/useSuggestedStarterPacksQuery'
7+
import {useOnboardingSuggestedStarterPacksQuery} from '#/state/queries/useOnboardingSuggestedStarterPacksQuery'
88
import {useOnboardingDispatch} from '#/state/shell'
99
import {OnboardingControls} from '#/screens/Onboarding/Layout'
1010
import {Context} from '#/screens/Onboarding/state'
@@ -34,12 +34,12 @@ export function StepSuggestedStarterpacks() {
3434
// }, [contentLanguages])
3535

3636
const {
37-
data: suggestedUsers,
37+
data: suggestedStarterPacks,
3838
isLoading,
3939
error,
4040
isRefetching,
4141
refetch,
42-
} = useSuggestedStarterPacksQuery({
42+
} = useOnboardingSuggestedStarterPacksQuery({
4343
enabled: true,
4444
overrideInterests: state.interestsStepResults.selectedInterests,
4545
})
@@ -53,7 +53,7 @@ export function StepSuggestedStarterpacks() {
5353

5454
return (
5555
<View style={[a.align_start]} testID="onboardingInterests">
56-
<Text style={[a.font_heavy, a.text_3xl]}>
56+
<Text style={[a.font_bold, a.text_3xl]}>
5757
<Trans comment="Accounts suggested to the user for them to follow">
5858
Suggested for you
5959
</Trans>
@@ -100,7 +100,7 @@ export function StepSuggestedStarterpacks() {
100100
</View>
101101
) : (
102102
<View style={[a.flex_1, a.mt_md]}>
103-
{suggestedUsers?.starterPacks.map(starterPack => (
103+
{suggestedStarterPacks?.starterPacks.map(starterPack => (
104104
<View style={[a.pb_lg]} key={starterPack.uri}>
105105
<StarterPackCard view={starterPack} />
106106
</View>
@@ -150,49 +150,3 @@ export function StepSuggestedStarterpacks() {
150150
</View>
151151
)
152152
}
153-
154-
// function TabBar({
155-
// selectedInterest,
156-
// onSelectInterest,
157-
// selectedInterests,
158-
// hideDefaultTab,
159-
// defaultTabLabel,
160-
// }: {
161-
// selectedInterest: string | null
162-
// onSelectInterest: (interest: string | null) => void
163-
// selectedInterests: string[]
164-
// hideDefaultTab?: boolean
165-
// defaultTabLabel?: string
166-
// }) {
167-
// const {_} = useLingui()
168-
// const interestsDisplayNames = useInterestsDisplayNames()
169-
// const interests = Object.keys(interestsDisplayNames)
170-
// .sort(boostInterests(popularInterests))
171-
// .sort(boostInterests(selectedInterests))
172-
173-
// return (
174-
// <InterestTabs
175-
// interests={hideDefaultTab ? interests : ['all', ...interests]}
176-
// selectedInterest={
177-
// selectedInterest || (hideDefaultTab ? interests[0] : 'all')
178-
// }
179-
// onSelectTab={tab => {
180-
// logger.metric(
181-
// 'onboarding:suggestedAccounts:tabPressed',
182-
// {tab: tab},
183-
// {statsig: true},
184-
// )
185-
// onSelectInterest(tab === 'all' ? null : tab)
186-
// }}
187-
// interestsDisplayNames={
188-
// hideDefaultTab
189-
// ? interestsDisplayNames
190-
// : {
191-
// all: defaultTabLabel || _(msg`For You`),
192-
// ...interestsDisplayNames,
193-
// }
194-
// }
195-
// gutterWidth={isWeb ? 0 : tokens.space.xl}
196-
// />
197-
// )
198-
// }
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import {useQuery} from '@tanstack/react-query'
2+
3+
import {
4+
aggregateUserInterests,
5+
createBskyTopicsHeader,
6+
} from '#/lib/api/feed/utils'
7+
import {getContentLanguages} from '#/state/preferences/languages'
8+
import {STALE} from '#/state/queries'
9+
import {usePreferencesQuery} from '#/state/queries/preferences'
10+
import {useAgent} from '#/state/session'
11+
12+
export const createOnboardingSuggestedStarterPacksQueryKey = (
13+
interests?: string[],
14+
) => ['onboarding-suggested-starter-packs', interests?.join(',')]
15+
16+
export function useOnboardingSuggestedStarterPacksQuery({
17+
enabled,
18+
overrideInterests,
19+
}: {
20+
enabled?: boolean
21+
overrideInterests?: string[]
22+
}) {
23+
const agent = useAgent()
24+
const {data: preferences} = usePreferencesQuery()
25+
const contentLangs = getContentLanguages().join(',')
26+
27+
return useQuery({
28+
enabled: !!preferences && enabled !== false,
29+
staleTime: STALE.MINUTES.THREE,
30+
queryKey: createOnboardingSuggestedStarterPacksQueryKey(overrideInterests),
31+
queryFn: async () => {
32+
const {data} =
33+
await agent.app.bsky.unspecced.getOnboardingSuggestedStarterPacks(
34+
{limit: 5},
35+
{
36+
headers: {
37+
...createBskyTopicsHeader(
38+
overrideInterests
39+
? overrideInterests.join(',')
40+
: aggregateUserInterests(preferences),
41+
),
42+
'Accept-Language': contentLangs,
43+
},
44+
},
45+
)
46+
return data
47+
},
48+
})
49+
}

0 commit comments

Comments
 (0)