diff options
Diffstat (limited to 'src/screens/Onboarding/util.ts')
-rw-r--r-- | src/screens/Onboarding/util.ts | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/screens/Onboarding/util.ts b/src/screens/Onboarding/util.ts index 2a709a67b..1a0b8d21b 100644 --- a/src/screens/Onboarding/util.ts +++ b/src/screens/Onboarding/util.ts @@ -2,6 +2,7 @@ import {AppBskyGraphFollow, AppBskyGraphGetFollows} from '@atproto/api' import {until} from '#/lib/async/until' import {getAgent} from '#/state/session' +import {PRIMARY_FEEDS} from './StepAlgoFeeds' function shuffle(array: any) { let currentIndex = array.length, @@ -31,7 +32,15 @@ export function aggregateInterestItems( const selected = interests.length const all = interests .map(i => { - const suggestions = shuffle(map[i]) + // suggestions from server + const rawSuggestions = map[i] + + // safeguard against a missing interest->suggestion mapping + if (!rawSuggestions || !rawSuggestions.length) { + return [] + } + + const suggestions = shuffle(rawSuggestions) if (selected === 1) { return suggestions // return all @@ -102,11 +111,19 @@ async function whenFollowsIndexed( * feed after Following */ export function sortPrimaryAlgorithmFeeds(uris: string[]) { - return uris.sort(uri => { - return uri.includes('the-algorithm') - ? -1 - : uri.includes('whats-hot') - ? 0 - : 1 + return uris.sort((a, b) => { + if (a === PRIMARY_FEEDS[0].uri) { + return -1 + } + if (b === PRIMARY_FEEDS[0].uri) { + return 1 + } + if (a === PRIMARY_FEEDS[1].uri) { + return -1 + } + if (b === PRIMARY_FEEDS[1].uri) { + return 1 + } + return a.localeCompare(b) }) } |