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 () => { (async () => {
// Interests need to get saved first, then we can write the feeds to prefs // Interests need to get saved first, then we can write the feeds to prefs
await agent.setInterestsPref({tags: selectedInterests}) await agent.setInterestsPref({tags: selectedInterests})
if (starterPack?.feeds?.length) { if (starterPack) {
await agent.addSavedFeeds( if (starterPack.feeds?.length) {
starterPack.feeds.map(f => ({ await agent.addSavedFeeds(
type: 'feed', starterPack.feeds.map(f => ({
value: f.uri, type: 'feed',
pinned: true, value: f.uri,
})), pinned: true,
) })),
)
setCurrentStarterPack({
uri: '',
initialFeed: starterPack.feeds?.[0].uri,
})
} else {
setCurrentStarterPack({
uri: '',
initialFeed: 'following',
})
}
addUsedStarterPack(makeStarterPackLink(starterPack))
} }
})(), })(),
(async () => { (async () => {
@@ -135,17 +147,12 @@ export function StepFinished() {
})(), })(),
requestNotificationsPermission('AfterOnboarding'), requestNotificationsPermission('AfterOnboarding'),
]) ])
if (currentStarterPack && starterPack) {
setCurrentStarterPack({
...currentStarterPack,
initialFeed: starterPack?.feeds?.[0].uri ?? 'following',
})
addUsedStarterPack(makeStarterPackLink(starterPack))
}
} catch (e: any) { } catch (e: any) {
logger.info(`onboarding: bulk save failed`) logger.info(`onboarding: bulk save failed`)
logger.error(e) 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 // don't alert the user, just let them into their account
} }
@@ -177,8 +184,8 @@ export function StepFinished() {
currentStarterPack, currentStarterPack,
state, state,
requestNotificationsPermission, requestNotificationsPermission,
setCurrentStarterPack,
addUsedStarterPack, addUsedStarterPack,
setCurrentStarterPack,
]) ])
React.useEffect(() => { React.useEffect(() => {
+4 -7
View File
@@ -105,13 +105,10 @@ function HomeScreenReady({
let initialIndex = selectedIndex let initialIndex = selectedIndex
if (currentStarterPack?.initialFeed) { if (currentStarterPack?.initialFeed) {
if (currentStarterPack.initialFeed === 'following') { if (currentStarterPack.initialFeed === 'following') {
initialIndex = allFeeds.findIndex(f => f === 'following') initialIndex = 1
} else { } else if (allFeeds.length >= 3) {
initialIndex = allFeeds.findIndex( initialIndex = 2
f => f === `feedgen|${currentStarterPack.initialFeed}`, } else if (initialIndex === -1) {
)
}
if (initialIndex === -1) {
initialIndex = 0 initialIndex = 0
} }
setCurrentStarterPack(undefined) setCurrentStarterPack(undefined)