Couple of starter packs tweaks (#4604)

This commit is contained in:
Hailey 2024-06-24 10:24:39 -07:00 committed by GitHub
parent f769564edf
commit 77a512ae32
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 57 additions and 63 deletions

View file

@ -40,12 +40,14 @@ export function StepFeeds({moderationOpts}: {moderationOpts: ModerationOpts}) {
const {data: popularFeedsPages, fetchNextPage} = useGetPopularFeedsQuery({
limit: 30,
})
const popularFeeds =
popularFeedsPages?.pages
.flatMap(page => page.feeds)
.filter(f => !savedFeeds?.some(sf => sf?.uri === f.uri)) ?? []
const popularFeeds = popularFeedsPages?.pages.flatMap(p => p.feeds) ?? []
const suggestedFeeds = savedFeeds?.concat(popularFeeds)
const suggestedFeeds =
savedFeeds.length === 0
? popularFeeds
: savedFeeds.concat(
popularFeeds.filter(f => !savedFeeds.some(sf => sf.uri === f.uri)),
)
const {data: searchedFeeds, isLoading: isLoadingSearch} =
useSearchPopularFeedsQuery({q: throttledQuery})
@ -56,6 +58,7 @@ export function StepFeeds({moderationOpts}: {moderationOpts: ModerationOpts}) {
return (
<WizardFeedCard
generator={item}
btnType="checkbox"
state={state}
dispatch={dispatch}
moderationOpts={moderationOpts}

View file

@ -45,6 +45,7 @@ export function StepProfiles({
return (
<WizardProfileCard
profile={item}
btnType="checkbox"
state={state}
dispatch={dispatch}
moderationOpts={moderationOpts}

View file

@ -21,6 +21,7 @@ import {NativeStackScreenProps} from '@react-navigation/native-stack'
import {logger} from '#/logger'
import {HITSLOP_10} from 'lib/constants'
import {createSanitizedDisplayName} from 'lib/moderation/create-sanitized-display-name'
import {CommonNavigatorParams, NavigationProp} from 'lib/routes/types'
import {logEvent} from 'lib/statsig/statsig'
import {sanitizeDisplayName} from 'lib/strings/display-names'
@ -170,15 +171,7 @@ function WizardInner({
)
const getDefaultName = () => {
let displayName
if (
currentProfile?.displayName != null &&
currentProfile?.displayName !== ''
) {
displayName = sanitizeDisplayName(currentProfile.displayName)
} else {
displayName = sanitizeHandle(currentProfile!.handle)
}
const displayName = createSanitizedDisplayName(currentProfile!, true)
return _(msg`${displayName}'s Starter Pack`).slice(0, 50)
}
@ -191,16 +184,12 @@ function WizardInner({
nextBtn: _(msg`Next`),
},
Profiles: {
header: _(msg`People`),
header: _(msg`Choose People`),
nextBtn: _(msg`Next`),
subtitle: _(
msg`Add people to your starter pack that you think others will enjoy following`,
),
},
Feeds: {
header: _(msg`Feeds`),
header: _(msg`Choose Feeds`),
nextBtn: state.feeds.length === 0 ? _(msg`Skip`) : _(msg`Finish`),
subtitle: _(msg`Some subtitle`),
},
}
const currUiStrings = wizardUiStrings[state.currentStep]
@ -254,8 +243,8 @@ function WizardInner({
dispatch({type: 'SetProcessing', processing: true})
if (currentStarterPack && currentListItems) {
editStarterPack({
name: state.name ?? getDefaultName(),
description: state.description,
name: state.name?.trim() || getDefaultName(),
description: state.description?.trim(),
descriptionFacets: [],
profiles: state.profiles,
feeds: state.feeds,
@ -264,8 +253,8 @@ function WizardInner({
})
} else {
createStarterPack({
name: state.name ?? getDefaultName(),
description: state.description,
name: state.name?.trim() || getDefaultName(),
description: state.description?.trim(),
descriptionFacets: [],
profiles: state.profiles,
feeds: state.feeds,
@ -483,13 +472,10 @@ function Footer({
</Trans>
) : items.length === 2 ? (
<Trans>
<Text style={[a.font_bold, textStyles]}>
{getName(items[initialNamesIndex])}{' '}
</Text>
and
<Text style={[a.font_bold, textStyles]}>You</Text> and
<Text> </Text>
<Text style={[a.font_bold, textStyles]}>
{getName(items[state.currentStep === 'Profiles' ? 0 : 1])}{' '}
{getName(items[initialNamesIndex])}{' '}
</Text>
are included in your starter pack
</Trans>
@ -579,9 +565,9 @@ function Footer({
function getName(item: AppBskyActorDefs.ProfileViewBasic | GeneratorView) {
if (typeof item.displayName === 'string') {
return enforceLen(sanitizeDisplayName(item.displayName), 16, true)
return enforceLen(sanitizeDisplayName(item.displayName), 28, true)
} else if (typeof item.handle === 'string') {
return enforceLen(sanitizeHandle(item.handle), 16, true)
return enforceLen(sanitizeHandle(item.handle), 28, true)
}
return ''
}