diff options
author | Paul Frazee <pfrazee@gmail.com> | 2024-01-31 16:42:48 -0800 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2024-01-31 16:42:48 -0800 |
commit | 2e3e66c974d1b614cfa4831f3eb1d95117bf10f3 (patch) | |
tree | 8d29d2eb5d9967e6faa19d7858f3c24f90daa945 | |
parent | 50eb1c30d2462bc04cb6ec9b82af7120e5a80614 (diff) | |
download | voidsky-2e3e66c974d1b614cfa4831f3eb1d95117bf10f3.tar.zst |
Fix sort
-rw-r--r-- | src/screens/Onboarding/StepAlgoFeeds/index.tsx | 2 | ||||
-rw-r--r-- | src/screens/Onboarding/util.ts | 21 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/screens/Onboarding/StepAlgoFeeds/index.tsx b/src/screens/Onboarding/StepAlgoFeeds/index.tsx index f2bf7cfb7..bc9262884 100644 --- a/src/screens/Onboarding/StepAlgoFeeds/index.tsx +++ b/src/screens/Onboarding/StepAlgoFeeds/index.tsx @@ -28,7 +28,7 @@ export type FeedConfig = { gradient?: typeof tokens.gradients.midnight | typeof tokens.gradients.nordic } -const PRIMARY_FEEDS: FeedConfig[] = [ +export const PRIMARY_FEEDS: FeedConfig[] = [ { default: IS_PROD, // these feeds are only available in prod uri: 'at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/whats-hot', diff --git a/src/screens/Onboarding/util.ts b/src/screens/Onboarding/util.ts index eae661aa4..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, @@ -110,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) }) } |