always put yourself in the starter pack
This commit is contained in:
@@ -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,6 +59,7 @@ export function WizardProfileCard({
|
|||||||
@{profile?.handle}
|
@{profile?.handle}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
{profile.did !== currentAccount?.did && (
|
||||||
<Button
|
<Button
|
||||||
label={includesProfile ? _(msg`Remove`) : _(msg`Add`)}
|
label={includesProfile ? _(msg`Remove`) : _(msg`Add`)}
|
||||||
variant="solid"
|
variant="solid"
|
||||||
@@ -68,6 +71,7 @@ export function WizardProfileCard({
|
|||||||
{includesProfile ? <Trans>Remove</Trans> : <Trans>Add</Trans>}
|
{includesProfile ? <Trans>Remove</Trans> : <Trans>Add</Trans>}
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
</Button>
|
</Button>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user