Remove old onboarding (#4224)

* Hardcode onboarding_v2 to true, rm dead code

* Rm initialState, use initialStateReduced

* Rm dead code

* Drop *reduced prefix in code

* Prettier
This commit is contained in:
dan
2024-05-28 16:56:06 +01:00
committed by GitHub
parent 9bd411c151
commit adbbded003
17 changed files with 27 additions and 1986 deletions
-76
View File
@@ -5,66 +5,6 @@ import {
} from '@atproto/api'
import {until} from '#/lib/async/until'
import {PRIMARY_FEEDS} from './StepAlgoFeeds'
function shuffle(array: any) {
let currentIndex = array.length,
randomIndex
// While there remain elements to shuffle.
while (currentIndex > 0) {
// Pick a remaining element.
randomIndex = Math.floor(Math.random() * currentIndex)
currentIndex--
// And swap it with the current element.
;[array[currentIndex], array[randomIndex]] = [
array[randomIndex],
array[currentIndex],
]
}
return array
}
export function aggregateInterestItems(
interests: string[],
map: {[key: string]: string[]},
fallbackItems: string[],
) {
const selected = interests.length
const all = interests
.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
} else if (selected === 2) {
return suggestions.slice(0, 5) // return 5
} else {
return suggestions.slice(0, 3) // return 3
}
})
.flat()
// dedupe suggestions
const results = Array.from(new Set(all))
// backfill
if (results.length < 20) {
results.push(...shuffle(fallbackItems))
}
// dedupe and return 20
return Array.from(new Set(results)).slice(0, 20)
}
export async function bulkWriteFollows(agent: BskyAgent, dids: string[]) {
const session = agent.session
@@ -109,19 +49,3 @@ async function whenFollowsIndexed(
}),
)
}
/**
* Kinda hacky, but we want Discover to appear as the first pinned
* feed after Following
*/
export function sortPrimaryAlgorithmFeeds(uris: string[]) {
return uris.sort((a, b) => {
if (a === PRIMARY_FEEDS[0]?.uri) {
return -1
}
if (b === PRIMARY_FEEDS[0]?.uri) {
return 1
}
return a.localeCompare(b)
})
}