Address PR review feedback for invite friends

- Remove commented-out Dialog.Handle in InviteFriendsDialog
- Defer NUX -> invite handoff with requestAnimationFrame instead of setTimeout
- Un-nest the dismiss Pressable in FollowersPromoBanner (avoids Android touch conflicts)
- Drop redundant toLowerCase in getInviteShareUrl (handles are API-normalized, matches makeProfileLink)
- Request write-only media library permission when saving the QR code
- Migrate InviteFriendsAnnouncement to the l macro
This commit is contained in:
vineyardbovines
2026-06-02 09:31:08 -04:00
parent bb9f0b9bbf
commit 218c997776
6 changed files with 58 additions and 54 deletions
@@ -1,9 +1,7 @@
import {useCallback} from 'react'
import {View} from 'react-native'
import {Image} from 'expo-image'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro'
import {Trans, useLingui} from '@lingui/react/macro'
import {atoms as a, useTheme, web} from '#/alf'
import {Button, ButtonText} from '#/components/Button'
@@ -22,7 +20,7 @@ export const enabled = createIsEnabledCheck(() => {
export function InviteFriendsAnnouncement() {
const t = useTheme()
const {_} = useLingui()
const {t: l} = useLingui()
const nuxDialogs = useNuxDialogContext()
const control = Dialog.useDialogControl()
@@ -37,9 +35,9 @@ export function InviteFriendsAnnouncement() {
// the invite dialog. The invite dialog is mounted persistently by NuxDialogs
// (not here) so it survives the dismissal - the native bottom sheet cannot
// hand off to a second sheet mounted in this same subtree. Defer the open to
// the next tick so the announcement's teardown completes first.
// the next frame so the announcement's teardown completes first.
control.close(() => {
setTimeout(() => nuxDialogs.openInviteFriends())
requestAnimationFrame(() => nuxDialogs.openInviteFriends())
})
}, [control, nuxDialogs])
@@ -52,7 +50,7 @@ export function InviteFriendsAnnouncement() {
<Dialog.Handle fill={t.palette.primary_400} />
<Dialog.ScrollableInner
label={_(msg`Invite your friends`)}
label={l`Invite your friends`}
style={[web({maxWidth: 440})]}
contentContainerStyle={[
{paddingTop: 0, paddingLeft: 0, paddingRight: 0},
@@ -72,9 +70,7 @@ export function InviteFriendsAnnouncement() {
accessibilityIgnoresInvertColors
source={require('../../../../assets/images/invite_friends_announcement_nux.webp')}
style={[a.w_full, {aspectRatio: 754 / 440}]}
alt={_(
msg`An illustration of the Bluesky app with a paper airplane flying out of it, representing inviting friends`,
)}
alt={l`An illustration of the Bluesky app with a paper airplane flying out of it, representing inviting friends`}
/>
<View
style={[
@@ -121,7 +117,7 @@ export function InviteFriendsAnnouncement() {
{!IS_WEB && (
<View style={[a.w_full, a.gap_sm]}>
<Button
label={_(msg`Try it`)}
label={l`Try it`}
size="large"
color="primary"
onPress={onPressTryIt}
@@ -131,7 +127,7 @@ export function InviteFriendsAnnouncement() {
</ButtonText>
</Button>
<Button
label={_(msg`Cancel`)}
label={l`Cancel`}
size="large"
color="secondary"
onPress={() => control.close()}
@@ -13,7 +13,6 @@ export function InviteFriendsDialog({
control={control}
onClose={onClose}
nativeOptions={{preventExpansion: true}}>
{/* <Dialog.Handle /> */}
<InviteFriendsDialogInner control={control} />
</Dialog.Outer>
)
@@ -2,8 +2,7 @@ import {Suspense, useRef, useState} from 'react'
import {Pressable, View} from 'react-native'
import type ViewShot from 'react-native-view-shot'
import {setStringAsync} from 'expo-clipboard'
import {requestMediaLibraryPermissionsAsync} from 'expo-image-picker'
import {createAssetAsync} from 'expo-media-library'
import {createAssetAsync, requestPermissionsAsync} from 'expo-media-library'
import {useLingui} from '@lingui/react/macro'
import {useNavigation} from '@react-navigation/native'
@@ -78,7 +77,9 @@ export function InviteFriendsDialogInner({
return
}
const permission = await requestMediaLibraryPermissionsAsync()
// Write-only permission - saving the QR image does not require read access
// to the user's photo library.
const permission = await requestPermissionsAsync(true)
if (!permission.granted) {
Toast.show(
l`You must grant access to your photo library to save the QR code`,
@@ -17,39 +17,47 @@ export function FollowersPromoBanner({
const t = useTheme()
return (
<View style={[a.px_lg, a.pt_md]}>
<Pressable
accessibilityRole="button"
accessibilityLabel={l`Find and invite friends`}
accessibilityHint={l`Opens the find and invite friends settings`}
onPress={onPress}
style={({pressed}) => [
a.flex_row,
a.align_center,
a.w_full,
{
height: 80,
borderRadius: 16,
backgroundColor: t.palette.primary_50,
paddingHorizontal: 16,
paddingVertical: 16,
opacity: pressed ? 0.85 : 1,
},
]}>
<Image
accessibilityIgnoresInvertColors
source={require('../../../../assets/images/invite_friends_promo_banner.webp')}
style={{width: 126, height: 64, marginRight: 16}}
contentFit="contain"
/>
<Text
style={[
a.flex_1,
a.text_md,
a.font_bold,
{color: t.palette.primary_700, lineHeight: 19.5},
{/*
* The dismiss button is a sibling of (not nested inside) the banner
* Pressable - nesting Pressables causes touch-handling conflicts on
* Android. This relative wrapper matches the banner bounds so the dismiss
* button can be positioned absolutely against the card's top-right corner.
*/}
<View style={[a.relative]}>
<Pressable
accessibilityRole="button"
accessibilityLabel={l`Find and invite friends`}
accessibilityHint={l`Opens the find and invite friends settings`}
onPress={onPress}
style={({pressed}) => [
a.flex_row,
a.align_center,
a.w_full,
{
height: 80,
borderRadius: 16,
backgroundColor: t.palette.primary_50,
paddingHorizontal: 16,
paddingVertical: 16,
opacity: pressed ? 0.85 : 1,
},
]}>
{l`Import contacts or invite your friends`}
</Text>
<Image
accessibilityIgnoresInvertColors
source={require('../../../../assets/images/invite_friends_promo_banner.webp')}
style={{width: 126, height: 64, marginRight: 16}}
contentFit="contain"
/>
<Text
style={[
a.flex_1,
a.text_md,
a.font_bold,
{color: t.palette.primary_700, lineHeight: 19.5},
]}>
{l`Import contacts or invite your friends`}
</Text>
</Pressable>
<Pressable
accessibilityRole="button"
accessibilityLabel={l`Dismiss`}
@@ -67,7 +75,7 @@ export function FollowersPromoBanner({
]}>
<TimesIcon width={12} height={12} fill={t.palette.contrast_500} />
</Pressable>
</Pressable>
</View>
</View>
)
}
+4 -4
View File
@@ -22,9 +22,9 @@ describe('invite URLs', () => {
)
})
it('lowercases the handle', () => {
it('passes the handle through verbatim (handles are API-normalized, like makeProfileLink)', () => {
expect(getInviteShareUrl('Alice.Bsky.Social')).toBe(
'https://bsky.app/profile/alice.bsky.social',
'https://bsky.app/profile/Alice.Bsky.Social',
)
})
@@ -45,9 +45,9 @@ describe('invite URLs', () => {
expect(getInviteDisplayUrl('alice')).toBe('bsky.app/profile/alice')
})
it('lowercases the handle', () => {
it('passes the handle through verbatim (handles are API-normalized, like makeProfileLink)', () => {
expect(getInviteDisplayUrl('Danielle.bsky.team')).toBe(
'bsky.app/profile/danielle.bsky.team',
'bsky.app/profile/Danielle.bsky.team',
)
})
+1 -1
View File
@@ -16,7 +16,7 @@ function stripLeadingAt(handle: string): string {
/** Canonical URL - used for QR payload, Share, and Copy. Empty handle -> empty string. */
export function getInviteShareUrl(handle: string): string {
const bare = stripLeadingAt(handle).toLowerCase()
const bare = stripLeadingAt(handle)
if (!bare) return ''
return `https://bsky.app/profile/${bare}`
}