better handling

This commit is contained in:
Hailey
2024-06-16 23:05:04 -07:00
parent d4631b404a
commit fa004bc8df
2 changed files with 28 additions and 24 deletions
+24 -17
View File
@@ -83,14 +83,26 @@ export function StepFinished() {
(async () => {
// Interests need to get saved first, then we can write the feeds to prefs
await agent.setInterestsPref({tags: selectedInterests})
if (starterPack?.feeds?.length) {
await agent.addSavedFeeds(
starterPack.feeds.map(f => ({
type: 'feed',
value: f.uri,
pinned: true,
})),
)
if (starterPack) {
if (starterPack.feeds?.length) {
await agent.addSavedFeeds(
starterPack.feeds.map(f => ({
type: 'feed',
value: f.uri,
pinned: true,
})),
)
setCurrentStarterPack({
uri: '',
initialFeed: starterPack.feeds?.[0].uri,
})
} else {
setCurrentStarterPack({
uri: '',
initialFeed: 'following',
})
}
addUsedStarterPack(makeStarterPackLink(starterPack))
}
})(),
(async () => {
@@ -135,17 +147,12 @@ export function StepFinished() {
})(),
requestNotificationsPermission('AfterOnboarding'),
])
if (currentStarterPack && starterPack) {
setCurrentStarterPack({
...currentStarterPack,
initialFeed: starterPack?.feeds?.[0].uri ?? 'following',
})
addUsedStarterPack(makeStarterPackLink(starterPack))
}
} catch (e: any) {
logger.info(`onboarding: bulk save failed`)
logger.error(e)
// If there was an error encountered, we need to just clear the starter pack so we don't break things for subsequent
// app restarts
setCurrentStarterPack(undefined)
// don't alert the user, just let them into their account
}
@@ -177,8 +184,8 @@ export function StepFinished() {
currentStarterPack,
state,
requestNotificationsPermission,
setCurrentStarterPack,
addUsedStarterPack,
setCurrentStarterPack,
])
React.useEffect(() => {
+4 -7
View File
@@ -105,13 +105,10 @@ function HomeScreenReady({
let initialIndex = selectedIndex
if (currentStarterPack?.initialFeed) {
if (currentStarterPack.initialFeed === 'following') {
initialIndex = allFeeds.findIndex(f => f === 'following')
} else {
initialIndex = allFeeds.findIndex(
f => f === `feedgen|${currentStarterPack.initialFeed}`,
)
}
if (initialIndex === -1) {
initialIndex = 1
} else if (allFeeds.length >= 3) {
initialIndex = 2
} else if (initialIndex === -1) {
initialIndex = 0
}
setCurrentStarterPack(undefined)