always put yourself in the starter pack

This commit is contained in:
Hailey
2024-06-11 10:19:03 -07:00
parent 0c8112c1b4
commit 49d9809a73
3 changed files with 41 additions and 15 deletions
@@ -4,6 +4,7 @@ import {AppBskyActorDefs} from '@atproto/api'
import {msg, Trans} from '@lingui/macro' import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {useSession} from 'state/session'
import {UserAvatar} from 'view/com/util/UserAvatar' import {UserAvatar} from 'view/com/util/UserAvatar'
import {WizardAction, WizardState} from '#/screens/StarterPack/Wizard/State' import {WizardAction, WizardState} from '#/screens/StarterPack/Wizard/State'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useTheme} from '#/alf'
@@ -21,6 +22,7 @@ export function WizardProfileCard({
}) { }) {
const {_} = useLingui() const {_} = useLingui()
const t = useTheme() const t = useTheme()
const {currentAccount} = useSession()
const includesProfile = state.profiles.some(p => p.did === profile.did) const includesProfile = state.profiles.some(p => p.did === profile.did)
@@ -57,17 +59,19 @@ export function WizardProfileCard({
@{profile?.handle} @{profile?.handle}
</Text> </Text>
</View> </View>
<Button {profile.did !== currentAccount?.did && (
label={includesProfile ? _(msg`Remove`) : _(msg`Add`)} <Button
variant="solid" label={includesProfile ? _(msg`Remove`) : _(msg`Add`)}
color={includesProfile ? 'secondary' : 'primary'} variant="solid"
size="small" color={includesProfile ? 'secondary' : 'primary'}
style={{paddingVertical: 6}} size="small"
onPress={onPressAddRemove}> style={{paddingVertical: 6}}
<ButtonText> onPress={onPressAddRemove}>
{includesProfile ? <Trans>Remove</Trans> : <Trans>Add</Trans>} <ButtonText>
</ButtonText> {includesProfile ? <Trans>Remove</Trans> : <Trans>Add</Trans>}
</Button> </ButtonText>
</Button>
)}
</View> </View>
) )
} }
+3 -1
View File
@@ -117,10 +117,12 @@ function reducer(state: State, action: Action): State {
export function Provider({ export function Provider({
starterPack, starterPack,
listItems, listItems,
profile,
children, children,
}: { }: {
starterPack?: AppBskyGraphDefs.StarterPackView starterPack?: AppBskyGraphDefs.StarterPackView
listItems?: AppBskyGraphDefs.ListItemView[] listItems?: AppBskyGraphDefs.ListItemView[]
profile: AppBskyActorDefs.ProfileView
children: React.ReactNode children: React.ReactNode
}) { }) {
const createInitialState = (): State => { const createInitialState = (): State => {
@@ -139,7 +141,7 @@ export function Provider({
return { return {
canNext: false, canNext: false,
currentStep: 'Details', currentStep: 'Details',
profiles: [], profiles: [profile],
feeds: [], feeds: [],
processing: false, processing: false,
} }
+23 -3
View File
@@ -52,6 +52,7 @@ export function Wizard({
}: NativeStackScreenProps<CommonNavigatorParams, 'StarterPackWizard'>) { }: NativeStackScreenProps<CommonNavigatorParams, 'StarterPackWizard'>) {
const params = route.params const params = route.params
const {name, rkey} = params ?? {} const {name, rkey} = params ?? {}
const {currentAccount} = useSession()
const {_} = useLingui() const {_} = useLingui()
@@ -76,6 +77,12 @@ export function Wizard({
} = useListMembersQuery(listUri, 51) // 51 because we also include the current user } = useListMembersQuery(listUri, 51) // 51 because we also include the current user
const listItems = profilesData?.pages.flatMap(p => p.items) const listItems = profilesData?.pages.flatMap(p => p.items)
const {
data: profile,
isLoading: isLoadingProfile,
isError: isErrorProfile,
} = useProfileQuery({did: currentAccount?.did})
if ( if (
name && name &&
rkey && rkey &&
@@ -88,10 +95,18 @@ export function Wizard({
errorMessage={_(msg`Could not find that starter pack`)} errorMessage={_(msg`Could not find that starter pack`)}
/> />
) )
} else if (!profile) {
return (
<ListMaybePlaceholder
isLoading={isLoadingProfile}
isError={isErrorProfile}
errorMessage={_(msg`Could not load your profile`)}
/>
)
} }
return ( return (
<Provider starterPack={starterPack} listItems={listItems}> <Provider starterPack={starterPack} listItems={listItems} profile={profile}>
<WizardInner <WizardInner
did={did} did={did}
rkey={rkey} rkey={rkey}
@@ -493,7 +508,7 @@ function Footer({
], ],
]}> ]}>
<View style={[a.flex_row, a.gap_xs]}> <View style={[a.flex_row, a.gap_xs]}>
{items.slice(0, 5).map((p, index) => ( {items.slice(0, 6).map((p, index) => (
<UserAvatar <UserAvatar
key={index} key={index}
avatar={p.avatar} avatar={p.avatar}
@@ -528,7 +543,12 @@ function Footer({
</View> </View>
) : ( ) : (
<Text style={[a.text_center, textStyles]}> <Text style={[a.text_center, textStyles]}>
{items.length === 1 ? ( {state.currentStep === 'Profiles' && items.length === 1 ? (
<Trans>
It's just you right now! Add more people to your starter pack by
searching above.
</Trans>
) : items.length === 1 ? (
<Trans> <Trans>
<Text style={[a.font_bold]}>{getName(items[0])}</Text> is included <Text style={[a.font_bold]}>{getName(items[0])}</Text> is included
in your starter pack in your starter pack