diff --git a/assets/icons/tmp/ui/Pencil_Stroke2_Corner2_Rounded.svg b/assets/icons/tmp/ui/Pencil_Stroke2_Corner2_Rounded.svg
new file mode 100644
index 000000000..e372ebe5e
--- /dev/null
+++ b/assets/icons/tmp/ui/Pencil_Stroke2_Corner2_Rounded.svg
@@ -0,0 +1 @@
+
diff --git a/src/analytics/metrics/types.ts b/src/analytics/metrics/types.ts
index 56a55c1d1..cc7d1bcb3 100644
--- a/src/analytics/metrics/types.ts
+++ b/src/analytics/metrics/types.ts
@@ -1578,6 +1578,20 @@ export type Events = {
* Edit Profile was opened, from any profile header.
*/
'profile:edit:open': {}
+ /**
+ * Edit Profile saved a change to the profile's pronouns. Never includes the
+ * pronouns themselves.
+ */
+ 'profile:pronouns:save':
+ | {action: 'remove'}
+ | {
+ action: 'add' | 'edit'
+ /**
+ * How the saved pronouns were entered: one suggestion, several
+ * suggestions combined, or custom text.
+ */
+ source: 'preset' | 'combined' | 'custom'
+ }
/**
* Edit Profile was opened with the Links section available.
*/
diff --git a/src/components/ProfileHoverCard/index.web.tsx b/src/components/ProfileHoverCard/index.web.tsx
index 9df5e41c1..50d2709d5 100644
--- a/src/components/ProfileHoverCard/index.web.tsx
+++ b/src/components/ProfileHoverCard/index.web.tsx
@@ -536,7 +536,11 @@ function Inner({
-
+
diff --git a/src/components/icons/Pencil.tsx b/src/components/icons/Pencil.tsx
index 4135e3936..835765958 100644
--- a/src/components/icons/Pencil.tsx
+++ b/src/components/icons/Pencil.tsx
@@ -8,6 +8,12 @@ export const Pencil_Stroke2_Corner0_Rounded = createSinglePathSVG({
glyph: 'Pencil_Stroke2_Corner0_Rounded',
})
+/** Temporary SVG-only icon. Move its source to assets/icons/ui/ before a native release. */
+export const Pencil_Stroke2_Corner2_Rounded = createSinglePathSVG({
+ path: 'M14.293 3.293a4.536 4.536 0 0 1 6.414 6.414L10.66 19.754c-.387.387-.87.66-1.4.79l-.228.048-5.368.894a1 1 0 0 1-1.15-1.15l.894-5.368a3 3 0 0 1 .838-1.628L14.293 3.293ZM5.66 14.753a1 1 0 0 0-.279.544l-.665 3.986 3.987-.664a1 1 0 0 0 .543-.28l7.84-7.84L13.5 6.915l-7.84 7.84ZM19.293 4.708a2.536 2.536 0 0 0-3.586 0l-.793.793L18.5 9.086l.793-.793c.99-.99.99-2.596 0-3.586Z',
+ viewBox: '0 0 24 24',
+})
+
export const PencilLine_Stroke2_Corner0_Rounded = createSinglePathSVG({
path: 'M15.586 2.5a2 2 0 0 1 2.828 0L21.5 5.586a2 2 0 0 1 0 2.828l-13 13A2 2 0 0 1 7.086 22H3a1 1 0 0 1-1-1v-4.086a2 2 0 0 1 .586-1.414l13-13ZM17 3.914l-13 13V20h3.086l13-13L17 3.914ZM13 21a1 1 0 0 1 1-1h7a1 1 0 1 1 0 2h-7a1 1 0 0 1-1-1Z',
viewBox: '0 0 24 24',
diff --git a/src/features/profileLinks/components/ProfileLinksEditor.tsx b/src/features/profileLinks/components/ProfileLinksEditor.tsx
index b98e7658e..65ebc7b05 100644
--- a/src/features/profileLinks/components/ProfileLinksEditor.tsx
+++ b/src/features/profileLinks/components/ProfileLinksEditor.tsx
@@ -7,7 +7,12 @@ import {Button, ButtonIcon, ButtonText} from '#/components/Button'
import {useDialogControl} from '#/components/Dialog'
import * as TextField from '#/components/forms/TextField'
import {PlusSmall_Stroke2_Corner0_Rounded as PlusIcon} from '#/components/icons/Plus'
-import {PILL_LEFT, PILL_RIGHT_TEXT, PILL_VERTICAL} from '../pillSize'
+import {
+ PILL_DASHED_BORDER,
+ PILL_LEFT,
+ PILL_RIGHT_TEXT,
+ PILL_VERTICAL,
+} from '../pillSize'
import {buildProfileRow, reorderLinks} from '../row'
import {MAX_PROFILE_LINKS, type ProfileLink} from '../types'
import {LinkFormDialog} from './LinkFormDialog'
@@ -138,11 +143,12 @@ function AddLinkPill({onPress}: {onPress: () => void}) {
style={{
// the outline variant draws a hairline on native; this wants a full point
borderStyle: 'dashed',
- borderWidth: 1,
+ borderWidth: PILL_DASHED_BORDER,
borderColor: t.palette.contrast_600,
- paddingVertical: PILL_VERTICAL,
- paddingLeft: PILL_LEFT,
- paddingRight: PILL_RIGHT_TEXT,
+ // less the border, so it's the same size as the solid pills
+ paddingVertical: PILL_VERTICAL - PILL_DASHED_BORDER,
+ paddingLeft: PILL_LEFT - PILL_DASHED_BORDER,
+ paddingRight: PILL_RIGHT_TEXT - PILL_DASHED_BORDER,
}}>
diff --git a/src/features/profileLinks/pillSize.ts b/src/features/profileLinks/pillSize.ts
index 554dc6da5..700c840f4 100644
--- a/src/features/profileLinks/pillSize.ts
+++ b/src/features/profileLinks/pillSize.ts
@@ -11,3 +11,9 @@ export const PILL_RIGHT_ARROW = 10
export const PILL_RIGHT_GRIP = 8
/** Right edge when the pill ends in plain text. */
export const PILL_RIGHT_TEXT = 12
+
+/**
+ * Border on the dashed "Add" pills. Solid pills have none, so the dashed ones
+ * take this off their padding to come out the same size.
+ */
+export const PILL_DASHED_BORDER = 1
diff --git a/src/lib/constants.ts b/src/lib/constants.ts
index 35a152502..972ebc25c 100644
--- a/src/lib/constants.ts
+++ b/src/lib/constants.ts
@@ -62,6 +62,7 @@ export function FEEDBACK_FORM_URL({
export const MAX_DISPLAY_NAME = 64
export const MAX_DESCRIPTION = 256
+export const MAX_PRONOUNS = 20
export const MAX_GRAPHEME_LENGTH = 300
diff --git a/src/screens/Profile/Header/EditProfileDialog.tsx b/src/screens/Profile/Header/EditProfileDialog.tsx
index 483d5b35e..68ff9ec74 100644
--- a/src/screens/Profile/Header/EditProfileDialog.tsx
+++ b/src/screens/Profile/Header/EditProfileDialog.tsx
@@ -19,6 +19,8 @@ import {Admonition} from '#/components/Admonition'
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
import * as Dialog from '#/components/Dialog'
import * as TextField from '#/components/forms/TextField'
+import {Pencil_Stroke2_Corner2_Rounded as PencilIcon} from '#/components/icons/Pencil'
+import {PlusSmall_Stroke2_Corner0_Rounded as PlusIcon} from '#/components/icons/Plus'
import {InlineLinkText} from '#/components/Link'
import {Loader} from '#/components/Loader'
import * as Prompt from '#/components/Prompt'
@@ -36,7 +38,16 @@ import {
useSetOwnProfileLinksCache,
useWriteProfileLinks,
} from '#/features/profileLinks'
+import {
+ PILL_DASHED_BORDER,
+ PILL_LEFT,
+ PILL_RIGHT_GRIP,
+ PILL_RIGHT_TEXT,
+ PILL_VERTICAL,
+} from '#/features/profileLinks/pillSize'
import {type app} from '#/lexicons'
+import {PRONOUN_SUGGESTIONS, PronounsDialog} from './PronounsDialog'
+import {describePronounsChange} from './pronounSuggestions'
export function EditProfileDialog({
profile,
@@ -106,7 +117,7 @@ function DialogInner({
setDirty: (dirty: boolean) => void
onPressCancel: () => void
}) {
- const {_} = useLingui()
+ const {_, i18n} = useLingui()
const t = useTheme()
const ax = useAnalytics()
const control = Dialog.useDialogContext()
@@ -128,6 +139,9 @@ function DialogInner({
const [displayName, setDisplayName] = useState(initialDisplayName)
const initialDescription = profile.description || ''
const [description, setDescription] = useState(initialDescription)
+ const initialPronouns = profile.pronouns || ''
+ const [pronouns, setPronouns] = useState(initialPronouns)
+ const pronounsControl = Dialog.useDialogControl()
const [userBanner, setUserBanner] = useState(
profile.banner,
)
@@ -170,6 +184,7 @@ function DialogInner({
const profileDirty =
displayName !== initialDisplayName ||
description !== initialDescription ||
+ pronouns !== initialPronouns ||
userAvatar !== profile.avatar ||
userBanner !== profile.banner
const linksDirty =
@@ -231,6 +246,7 @@ function DialogInner({
updates: {
displayName: displayName.trimEnd(),
description: description.trimEnd(),
+ ...(pronouns !== initialPronouns && {pronouns: pronouns.trim()}),
...(written && {
links: written.refs.length ? written.refs : undefined,
}),
@@ -238,6 +254,14 @@ function DialogInner({
newUserAvatar,
newUserBanner,
})
+ const pronounsChange = describePronounsChange(
+ initialPronouns,
+ pronouns,
+ PRONOUN_SUGGESTIONS.map(s => i18n._(s)),
+ )
+ if (pronounsChange) {
+ ax.metric('profile:pronouns:save', pronounsChange)
+ }
if (nextLinks && written) {
logProfileLinkChanges(
ax,
@@ -259,10 +283,13 @@ function DialogInner({
control,
displayName,
description,
+ pronouns,
+ initialPronouns,
newUserAvatar,
newUserBanner,
setImageError,
_,
+ i18n,
editedLinks,
linksDirty,
storedLinks,
@@ -427,6 +454,74 @@ function DialogInner({
)}
+
+
+ Pronouns
+
+ {/*
+ * A pill that opens a sheet, rather than a full field, so pronouns
+ * stay optional and out of the way. It matches the link pills.
+ */}
+
+
+
+
+
+
Description
diff --git a/src/screens/Profile/Header/Handle.tsx b/src/screens/Profile/Header/Handle.tsx
index ecbb232af..ba8fe2b7a 100644
--- a/src/screens/Profile/Header/Handle.tsx
+++ b/src/screens/Profile/Header/Handle.tsx
@@ -1,4 +1,5 @@
import {View} from 'react-native'
+import {type ModerationDecision} from '@bsky/sdk/moderation'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro'
@@ -13,15 +14,20 @@ import {type app} from '#/lexicons'
export function ProfileHeaderHandle({
profile,
+ moderation,
disableTaps,
}: {
profile: Shadow
+ moderation: ModerationDecision
disableTaps?: boolean
}) {
const t = useTheme()
const {_} = useLingui()
const invalidHandle = isInvalidHandle(profile.handle)
const blockHide = profile.viewer?.blocking || profile.viewer?.blockedBy
+ const pronouns = profile.pronouns?.trim()
+ const showPronouns =
+ !!pronouns && !blockHide && !moderation.ui('profileView').blur
return (
) : undefined}
-
- {invalidHandle
- ? _(msg`⚠Invalid Handle`)
- : sanitizeHandle(
- profile.handle,
- '@',
- // forceLTR handled by CSS above on web
- IS_NATIVE,
- )}
-
+ {/*
+ * Inner row so a long handle shortens while the pronouns stay whole. The
+ * 10pt gap matches the spacing between the follower counts in Metrics.tsx.
+ */}
+
+
+ {invalidHandle
+ ? _(msg`⚠Invalid Handle`)
+ : sanitizeHandle(
+ profile.handle,
+ '@',
+ // forceLTR handled by CSS above on web
+ IS_NATIVE,
+ )}
+
+ {showPronouns && (
+ // the handle truncates first so pronouns stay whole on the same line
+
+ {pronouns}
+
+ )}
+
)
}
diff --git a/src/screens/Profile/Header/Metrics.tsx b/src/screens/Profile/Header/Metrics.tsx
index 84d25f761..7fe1d9e30 100644
--- a/src/screens/Profile/Header/Metrics.tsx
+++ b/src/screens/Profile/Header/Metrics.tsx
@@ -30,7 +30,8 @@ export function ProfileHeaderMetrics({
return (
-
+
{!isPlaceholderProfile && (
<>
diff --git a/src/screens/Profile/Header/ProfileHeaderStandard.tsx b/src/screens/Profile/Header/ProfileHeaderStandard.tsx
index b14e08905..0972b1531 100644
--- a/src/screens/Profile/Header/ProfileHeaderStandard.tsx
+++ b/src/screens/Profile/Header/ProfileHeaderStandard.tsx
@@ -139,7 +139,7 @@ let ProfileHeaderStandard = ({
profile={profile}
moderation={moderation}
/>
-
+
{!isPlaceholderProfile && !isBlockedUser && (
diff --git a/src/screens/Profile/Header/PronounsDialog.tsx b/src/screens/Profile/Header/PronounsDialog.tsx
new file mode 100644
index 000000000..8e28fa1b8
--- /dev/null
+++ b/src/screens/Profile/Header/PronounsDialog.tsx
@@ -0,0 +1,259 @@
+import {useState} from 'react'
+import {View} from 'react-native'
+import {msg} from '@lingui/core/macro'
+import {Plural, Trans, useLingui} from '@lingui/react/macro'
+import {countGraphemes} from 'unicode-segmenter/grapheme'
+
+import {MAX_PRONOUNS} from '#/lib/constants'
+import {atoms as a, tokens, useTheme, web} from '#/alf'
+import {Button, ButtonIcon, ButtonText} from '#/components/Button'
+import * as Dialog from '#/components/Dialog'
+import * as TextField from '#/components/forms/TextField'
+import {CheckThick_Stroke2_Corner0_Rounded as CheckIcon} from '#/components/icons/Check'
+import {type Props as SVGIconProps} from '#/components/icons/common'
+import {TimesLarge_Stroke2_Corner0_Rounded as XIcon} from '#/components/icons/TimesLarge'
+import {Text} from '#/components/Typography'
+import {IS_LIQUID_GLASS} from '#/env'
+import {parsePronouns, togglePronoun} from './pronounSuggestions'
+
+/**
+ * The field's character count only appears from this many characters, so it
+ * shows up as someone nears the limit rather than all the time.
+ */
+const SHOW_COUNT_FROM = 12
+
+/**
+ * Quick picks shown above the pronouns field. They only fill in the field, so
+ * people can still type anything that fits.
+ */
+export const PRONOUN_SUGGESTIONS = [
+ msg({
+ message: 'she/her',
+ comment:
+ 'Suggested pronouns in Edit Profile. Keep the “subject/object” shape if your language has one: picking several suggestions combines the part before the slash, e.g. “she/they”.',
+ }),
+ msg({
+ message: 'he/him',
+ comment:
+ 'Suggested pronouns in Edit Profile. Keep the “subject/object” shape if your language has one: picking several suggestions combines the part before the slash, e.g. “he/they”.',
+ }),
+ msg({
+ message: 'they/them',
+ comment:
+ 'Suggested pronouns in Edit Profile. Keep the “subject/object” shape if your language has one: picking several suggestions combines the part before the slash, e.g. “they/she”.',
+ }),
+]
+
+/**
+ * Adds, edits or removes the profile's pronouns. It only edits the Edit
+ * Profile draft; the profile is written when that dialog saves.
+ */
+export function PronounsDialog({
+ control,
+ pronouns,
+ onSave,
+}: {
+ control: Dialog.DialogControlProps
+ pronouns: string
+ /** Runs after the sheet closes, with the trimmed pronouns or "". */
+ onSave: (pronouns: string) => void
+}) {
+ return (
+
+
+
+
+ )
+}
+
+function PronounsDialogInner({
+ pronouns: initialPronouns,
+ onSave,
+}: {
+ pronouns: string
+ onSave: (pronouns: string) => void
+}) {
+ const control = Dialog.useDialogContext()
+ const {t: l, i18n} = useLingui()
+ const t = useTheme()
+ const [pronouns, setPronouns] = useState(initialPronouns)
+
+ const isEditing = !!initialPronouns
+ // graphemes, to match the lexicon's maxGraphemes limit
+ const length = countGraphemes(pronouns)
+ const tooLong = length > MAX_PRONOUNS
+ const suggestions = PRONOUN_SUGGESTIONS.map(s => i18n._(s))
+ const picked = parsePronouns(pronouns, suggestions) ?? []
+
+ const save = (next: string) => {
+ if (tooLong) return
+ control.close(() => onSave(next.trim()))
+ }
+
+ const closeInset = IS_LIQUID_GLASS ? tokens.space._2xl : tokens.space.xl
+
+ return (
+
+
+
+
+
+ {isEditing ? (
+ Edit pronouns
+ ) : (
+ Add pronouns
+ )}
+
+
+
+ Your pronouns show next to your handle on your profile.
+
+
+
+
+
+ {/* Pills first: most people pick one, and the field stays clear of the keyboard */}
+
+ {suggestions.map((value, index) => {
+ const selected = picked.includes(index)
+ return (
+
+ )
+ })}
+
+
+
+ save(pronouns)}
+ />
+ {length >= SHOW_COUNT_FROM && (
+
+ {length}/{MAX_PRONOUNS}
+
+ )}
+
+ {tooLong && (
+
+
+
+ )}
+
+
+
+
+
+ {isEditing && (
+
+ )}
+
+
+
+ )
+}
+
+/**
+ * Icon sizes come in fixed steps (8, 12, 16...), so this draws the check at
+ * 10pt, centered in the space ButtonIcon gives it.
+ */
+function SmallCheckIcon({width, ...props}: SVGIconProps) {
+ return (
+
+
+
+ )
+}
diff --git a/src/screens/Profile/Header/pronounSuggestions.test.ts b/src/screens/Profile/Header/pronounSuggestions.test.ts
new file mode 100644
index 000000000..17fd077d9
--- /dev/null
+++ b/src/screens/Profile/Header/pronounSuggestions.test.ts
@@ -0,0 +1,114 @@
+import {
+ composePronouns,
+ describePronounsChange,
+ parsePronouns,
+ togglePronoun,
+} from './pronounSuggestions'
+
+const SUGGESTIONS = ['she/her', 'he/him', 'they/them']
+const SHE = 0
+const HE = 1
+const THEY = 2
+
+describe('parsePronouns', () => {
+ it('treats empty text as nothing picked', () => {
+ expect(parsePronouns('', SUGGESTIONS)).toEqual([])
+ expect(parsePronouns(' ', SUGGESTIONS)).toEqual([])
+ })
+
+ it('matches a full form', () => {
+ expect(parsePronouns('she/her', SUGGESTIONS)).toEqual([SHE])
+ expect(parsePronouns('they/them', SUGGESTIONS)).toEqual([THEY])
+ })
+
+ it('matches combined subject forms in order', () => {
+ expect(parsePronouns('she/they', SUGGESTIONS)).toEqual([SHE, THEY])
+ expect(parsePronouns('they/she', SUGGESTIONS)).toEqual([THEY, SHE])
+ expect(parsePronouns('she/he/they', SUGGESTIONS)).toEqual([SHE, HE, THEY])
+ })
+
+ it('ignores case and spacing', () => {
+ expect(parsePronouns(' She/Her ', SUGGESTIONS)).toEqual([SHE])
+ expect(parsePronouns('he / they', SUGGESTIONS)).toEqual([HE, THEY])
+ })
+
+ it('returns null for text the suggestions do not cover', () => {
+ expect(parsePronouns('xe/xem', SUGGESTIONS)).toBeNull()
+ expect(parsePronouns('she', SUGGESTIONS)).toBeNull()
+ expect(parsePronouns('she/her/they', SUGGESTIONS)).toBeNull()
+ expect(parsePronouns('she/she', SUGGESTIONS)).toBeNull()
+ expect(parsePronouns('any pronouns', SUGGESTIONS)).toBeNull()
+ })
+})
+
+describe('composePronouns', () => {
+ it('uses the full form for a single pick', () => {
+ expect(composePronouns([], SUGGESTIONS)).toBe('')
+ expect(composePronouns([HE], SUGGESTIONS)).toBe('he/him')
+ })
+
+ it('joins subject forms for several picks', () => {
+ expect(composePronouns([SHE, THEY], SUGGESTIONS)).toBe('she/they')
+ expect(composePronouns([THEY, HE], SUGGESTIONS)).toBe('they/he')
+ })
+
+ it('handles suggestions without a slash', () => {
+ expect(composePronouns([0, 1], ['ella', 'elle'])).toBe('ella/elle')
+ })
+})
+
+describe('togglePronoun', () => {
+ it('picks, combines, and removes in tap order', () => {
+ let value = ''
+ value = togglePronoun(value, SHE, SUGGESTIONS)
+ expect(value).toBe('she/her')
+ value = togglePronoun(value, THEY, SUGGESTIONS)
+ expect(value).toBe('she/they')
+ value = togglePronoun(value, HE, SUGGESTIONS)
+ expect(value).toBe('she/they/he')
+ value = togglePronoun(value, SHE, SUGGESTIONS)
+ expect(value).toBe('they/he')
+ value = togglePronoun(value, HE, SUGGESTIONS)
+ expect(value).toBe('they/them')
+ value = togglePronoun(value, THEY, SUGGESTIONS)
+ expect(value).toBe('')
+ })
+
+ it('replaces custom text', () => {
+ expect(togglePronoun('xe/xem', SHE, SUGGESTIONS)).toBe('she/her')
+ })
+
+ it('builds on typed combos', () => {
+ expect(togglePronoun('He/They', SHE, SUGGESTIONS)).toBe('he/they/she')
+ })
+})
+
+describe('describePronounsChange', () => {
+ it('ignores unchanged pronouns', () => {
+ expect(describePronounsChange('she/her', ' she/her ', SUGGESTIONS)).toBe(
+ undefined,
+ )
+ expect(describePronounsChange('', '', SUGGESTIONS)).toBe(undefined)
+ })
+
+ it('tells adds, edits and removes apart', () => {
+ expect(describePronounsChange('', 'she/her', SUGGESTIONS)).toEqual({
+ action: 'add',
+ source: 'preset',
+ })
+ expect(describePronounsChange('she/her', 'she/they', SUGGESTIONS)).toEqual({
+ action: 'edit',
+ source: 'combined',
+ })
+ expect(describePronounsChange('she/her', '', SUGGESTIONS)).toEqual({
+ action: 'remove',
+ })
+ })
+
+ it('reports custom text without including it', () => {
+ expect(describePronounsChange('', 'xe/xem', SUGGESTIONS)).toEqual({
+ action: 'add',
+ source: 'custom',
+ })
+ })
+})
diff --git a/src/screens/Profile/Header/pronounSuggestions.ts b/src/screens/Profile/Header/pronounSuggestions.ts
new file mode 100644
index 000000000..968fc73ee
--- /dev/null
+++ b/src/screens/Profile/Header/pronounSuggestions.ts
@@ -0,0 +1,92 @@
+/*
+ * Helpers for the pronoun quick picks in Edit Profile. Suggestions are full
+ * "subject/object" forms like "she/her". One pick fills in the full form, and
+ * several picks combine their subject forms in pick order, e.g. "she/they".
+ */
+
+/**
+ * The subject form of a suggestion, e.g. "she" for "she/her".
+ */
+function subjectOf(suggestion: string) {
+ return suggestion.split('/')[0].trim()
+}
+
+function normalize(text: string) {
+ return text.trim().toLocaleLowerCase()
+}
+
+/**
+ * Which suggestions `value` is made of, as indexes into `suggestions` in the
+ * order they appear. Returns `null` when `value` has anything the suggestions
+ * don't cover, e.g. custom pronouns.
+ */
+export function parsePronouns(
+ value: string,
+ suggestions: string[],
+): number[] | null {
+ const text = normalize(value)
+ if (!text) return []
+
+ const full = suggestions.findIndex(s => normalize(s) === text)
+ if (full !== -1) return [full]
+
+ const subjects = suggestions.map(s => normalize(subjectOf(s)))
+ const indexes: number[] = []
+ for (const part of text.split('/')) {
+ const index = subjects.indexOf(part.trim())
+ if (index === -1 || indexes.includes(index)) return null
+ indexes.push(index)
+ }
+ return indexes.length > 1 ? indexes : null
+}
+
+/**
+ * Builds the pronouns text for the picked suggestions, in pick order.
+ */
+export function composePronouns(indexes: number[], suggestions: string[]) {
+ if (indexes.length === 0) return ''
+ if (indexes.length === 1) return suggestions[indexes[0]]
+ return indexes.map(i => subjectOf(suggestions[i])).join('/')
+}
+
+/**
+ * The new pronouns text after tapping the suggestion at `index`. Tapping a
+ * picked suggestion removes it, and tapping one while `value` holds custom
+ * text replaces that text.
+ */
+export function togglePronoun(
+ value: string,
+ index: number,
+ suggestions: string[],
+) {
+ const picked = parsePronouns(value, suggestions)
+ if (!picked) return composePronouns([index], suggestions)
+ const next = picked.includes(index)
+ ? picked.filter(i => i !== index)
+ : [...picked, index]
+ return composePronouns(next, suggestions)
+}
+
+/**
+ * What changed in the pronouns on save, for the `profile:pronouns:save`
+ * metric. Never includes the text itself, only how it was entered. Returns
+ * `undefined` when nothing changed beyond surrounding whitespace.
+ */
+export function describePronounsChange(
+ previous: string,
+ next: string,
+ suggestions: string[],
+):
+ | {action: 'remove'}
+ | {action: 'add' | 'edit'; source: 'preset' | 'combined' | 'custom'}
+ | undefined {
+ const before = previous.trim()
+ const after = next.trim()
+ if (before === after) return undefined
+ if (!after) return {action: 'remove'}
+ const picked = parsePronouns(after, suggestions)
+ return {
+ action: before ? 'edit' : 'add',
+ source: !picked ? 'custom' : picked.length > 1 ? 'combined' : 'preset',
+ }
+}
diff --git a/src/state/queries/profile.ts b/src/state/queries/profile.ts
index 1475b0807..26ef357ba 100644
--- a/src/state/queries/profile.ts
+++ b/src/state/queries/profile.ts
@@ -193,6 +193,9 @@ export function useProfileUpdateMutation() {
if ('links' in updates) {
next.links = updates.links
}
+ if ('pronouns' in updates) {
+ next.pronouns = updates.pronouns || undefined
+ }
}
if (newUserAvatarPromise) {
const res = await newUserAvatarPromise
@@ -243,6 +246,12 @@ export function useProfileUpdateMutation() {
// links come from separate records, so compare those too
return false
}
+ if (
+ 'pronouns' in updates &&
+ (fresh.pronouns || undefined) !== (updates.pronouns || undefined)
+ ) {
+ return false
+ }
return (
fresh.displayName === updates.displayName &&
fresh.description === updates.description
diff --git a/src/view/com/composer/ComposerReplyTo.tsx b/src/view/com/composer/ComposerReplyTo.tsx
index 175cda7d3..3fcc0f7c4 100644
--- a/src/view/com/composer/ComposerReplyTo.tsx
+++ b/src/view/com/composer/ComposerReplyTo.tsx
@@ -21,6 +21,9 @@ export function ComposerReplyTo({replyTo}: {replyTo: ComposerOptsPostRef}) {
const t = useTheme()
const {_} = useLingui()
const {embed} = replyTo
+ const pronouns = replyTo.moderation?.ui('profileView').blur
+ ? undefined
+ : replyTo.author.pronouns?.trim()
const [showFull, setShowFull] = useState(false)
@@ -117,6 +120,24 @@ export function ComposerReplyTo({replyTo}: {replyTo: ComposerOptsPostRef}) {
)}
+ {pronouns && (
+ // the display name truncates first so pronouns stay whole
+
+ {pronouns}
+
+ )}