Add back starter packs button in ProfileMenu (#10069)
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
|||||||
useListMembershipRemoveMutation,
|
useListMembershipRemoveMutation,
|
||||||
} from '#/state/queries/list-memberships'
|
} from '#/state/queries/list-memberships'
|
||||||
import {useProfileQuery} from '#/state/queries/profile'
|
import {useProfileQuery} from '#/state/queries/profile'
|
||||||
|
import {useSession} from '#/state/session'
|
||||||
import {atoms as a, native, platform, useTheme} from '#/alf'
|
import {atoms as a, native, platform, useTheme} from '#/alf'
|
||||||
import {AvatarStack} from '#/components/AvatarStack'
|
import {AvatarStack} from '#/components/AvatarStack'
|
||||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
@@ -260,6 +261,8 @@ function StarterPackItem({
|
|||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const ax = useAnalytics()
|
const ax = useAnalytics()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
const {currentAccount} = useSession()
|
||||||
|
const isSelf = subject?.did === currentAccount?.did
|
||||||
|
|
||||||
const starterPack = starterPackWithMembership.starterPack
|
const starterPack = starterPackWithMembership.starterPack
|
||||||
const isInPack = !!starterPackWithMembership.listItem
|
const isInPack = !!starterPackWithMembership.listItem
|
||||||
@@ -373,11 +376,17 @@ function StarterPackItem({
|
|||||||
label={isInPack ? _(msg`Remove`) : _(msg`Add`)}
|
label={isInPack ? _(msg`Remove`) : _(msg`Add`)}
|
||||||
color={isInPack ? 'secondary' : 'primary_subtle'}
|
color={isInPack ? 'secondary' : 'primary_subtle'}
|
||||||
size="tiny"
|
size="tiny"
|
||||||
disabled={isPending}
|
disabled={isPending || isSelf}
|
||||||
onPress={handleToggleMembership}>
|
onPress={handleToggleMembership}>
|
||||||
{isPending && <ButtonIcon icon={Loader} />}
|
{isPending && <ButtonIcon icon={Loader} />}
|
||||||
<ButtonText>
|
<ButtonText>
|
||||||
{isInPack ? <Trans>Remove</Trans> : <Trans>Add</Trans>}
|
{isSelf ? (
|
||||||
|
<Trans>Owner</Trans>
|
||||||
|
) : isInPack ? (
|
||||||
|
<Trans>Remove</Trans>
|
||||||
|
) : (
|
||||||
|
<Trans>Add</Trans>
|
||||||
|
)}
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
</Button>
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -341,17 +341,15 @@ let ProfileMenu = ({
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{!isSelf && (
|
<Menu.Item
|
||||||
<Menu.Item
|
testID="profileHeaderDropdownStarterPackAddRemoveBtn"
|
||||||
testID="profileHeaderDropdownStarterPackAddRemoveBtn"
|
label={_(msg`Add to starter packs`)}
|
||||||
label={_(msg`Add to starter packs`)}
|
onPress={onPressAddToStarterPacks}>
|
||||||
onPress={onPressAddToStarterPacks}>
|
<Menu.ItemText>
|
||||||
<Menu.ItemText>
|
<Trans>Add to starter packs</Trans>
|
||||||
<Trans>Add to starter packs</Trans>
|
</Menu.ItemText>
|
||||||
</Menu.ItemText>
|
<Menu.ItemIcon icon={StarterPack} />
|
||||||
<Menu.ItemIcon icon={StarterPack} />
|
</Menu.Item>
|
||||||
</Menu.Item>
|
|
||||||
)}
|
|
||||||
<Menu.Item
|
<Menu.Item
|
||||||
testID="profileHeaderDropdownListAddRemoveBtn"
|
testID="profileHeaderDropdownListAddRemoveBtn"
|
||||||
label={_(msg`Add to lists`)}
|
label={_(msg`Add to lists`)}
|
||||||
|
|||||||
Reference in New Issue
Block a user