From e34080c4a0a8656c8a38af6d1efdbbbb3054dc70 Mon Sep 17 00:00:00 2001 From: DS Boyce <260543580+ds-boyce@users.noreply.github.com> Date: Mon, 4 May 2026 22:44:31 +0100 Subject: [PATCH] Fix some minor issues with the invite link dialog (#10408) --- .../Messages/components/InviteLinkDialog.tsx | 63 ++++++++++--------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/src/screens/Messages/components/InviteLinkDialog.tsx b/src/screens/Messages/components/InviteLinkDialog.tsx index 843f6a833e..6071562d86 100644 --- a/src/screens/Messages/components/InviteLinkDialog.tsx +++ b/src/screens/Messages/components/InviteLinkDialog.tsx @@ -1,4 +1,4 @@ -import {useState} from 'react' +import {useEffect, useState} from 'react' import {View} from 'react-native' import {Trans, useLingui} from '@lingui/react/macro' @@ -36,16 +36,6 @@ enum Step { MANAGE, } -const timeFormatter = new Intl.DateTimeFormat(undefined, { - hour: 'numeric', - minute: 'numeric', -}) -const dateFormatter = new Intl.DateTimeFormat(undefined, { - month: 'long', - day: 'numeric', - year: 'numeric', -}) - export function InviteLinkDialog({ convo, control, @@ -56,7 +46,7 @@ export function InviteLinkDialog({ isOwner: boolean }) { const t = useTheme() - const {t: l} = useLingui() + const {t: l, i18n} = useLingui() const ownerName = createSanitizedDisplayName(convo.primaryMember) @@ -70,9 +60,20 @@ export function InviteLinkDialog({ ] : ['anyone'] - const [step, setStep] = useState(defaultStep) + const [step, setStep] = useState(defaultStep) const [whoCanJoin, setWhoCanJoin] = useState(defaultWhoCanJoin) + // Resync local state when the server-side join link rules change (mutation + // success, refetch, or change from another client). Keyed on the rule string + // so identity-only refetches don't bump a user mid-edit. + const joinLinkRuleKey = joinLink + ? `${joinLink.joinRule}${joinLink.requireApproval ? ':requireApproval' : ''}` + : null + useEffect(() => { + setStep(joinLinkRuleKey ? Step.MANAGE : Step.INFO) + setWhoCanJoin([joinLinkRuleKey ?? 'anyone']) + }, [joinLinkRuleKey]) + const {openComposer} = useOpenComposer() const {mutate: createJoinLink, isPending: isCreating} = useCreateJoinLink( @@ -204,7 +205,7 @@ export function InviteLinkDialog({ {whoCanJoinOptions.map(option => ( @@ -253,13 +254,15 @@ export function InviteLinkDialog({ ) break case Step.MANAGE: { - const hasJoinLinkCode = joinLink && joinLink.code !== '' - const joinLinkURI = hasJoinLinkCode + const joinLinkURI = joinLink?.code ? `https://bsky.app/chat/${joinLink.code}` : 'https://bsky.app/chat' const createdAt = joinLink ? new Date(joinLink.createdAt) : null + const currentOptionName = joinLink + ? `${joinLink.joinRule}${joinLink.requireApproval ? ':requireApproval' : ''}` + : whoCanJoinOptions[0].name const currentOption = whoCanJoinOptions.find( - o => o.name === whoCanJoin[0], + o => o.name === currentOptionName, ) const ownerValue = currentOption?.owner ?? whoCanJoinOptions[0].owner const memberValue = currentOption?.member ?? whoCanJoinOptions[0].member @@ -269,7 +272,7 @@ export function InviteLinkDialog({ <> - Created {timeFormatter.format(createdAt)}{' '} - {dateFormatter.format(createdAt)} + Created{' '} + {i18n.date(createdAt, { + dateStyle: 'long', + timeStyle: 'short', + })} ) : null} @@ -300,16 +306,11 @@ export function InviteLinkDialog({ label={l`Edit link settings`} value={ownerValue} onPress={() => setStep(Step.GENERATE)}> - - {ownerValue} - + + + {ownerValue} + + ) : ( {memberValue} @@ -391,7 +392,7 @@ export function InviteLinkDialog({ } } - if (!isOwner && (!joinLink || joinLink?.enabledStatus === 'disabled')) { + if (!isOwner && (!joinLink || joinLink.enabledStatus === 'disabled')) { header = l`Invite link` content = ( <>