Add confirm modal when setting pnp to not discoverable

This commit is contained in:
Jamie Kyle 2024-03-26 08:37:19 -07:00 committed by GitHub
parent f29fc7cf9d
commit 79035f5570
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 54 additions and 1 deletions

View file

@ -6078,6 +6078,14 @@
"messageformat": "Nobody", "messageformat": "Nobody",
"description": "Option for letting nobody discover you by phone number" "description": "Option for letting nobody discover you by phone number"
}, },
"icu:Preferences__pnp__discoverability__nobody__confirmModal__title": {
"messageformat": "Are you sure?",
"description": "Title for the confirmation modal when turning the phone number discoverability setting to nobody"
},
"icu:Preferences__pnp__discoverability__nobody__confirmModal__description": {
"messageformat": "If you change “{settingTitle}” to “{nobodyLabel}” it will make it harder for people to find you on Signal.",
"description": "Description for the confirmation modal when turning the phone number discoverability setting to nobody"
},
"icu:Preferences--messaging": { "icu:Preferences--messaging": {
"messageformat": "Messaging", "messageformat": "Messaging",
"description": "Title for the messaging settings" "description": "Title for the messaging settings"

View file

@ -363,6 +363,8 @@ export function Preferences({
>(localeOverride); >(localeOverride);
const [languageSearchInput, setLanguageSearchInput] = useState(''); const [languageSearchInput, setLanguageSearchInput] = useState('');
const [toast, setToast] = useState<AnyToast | undefined>(); const [toast, setToast] = useState<AnyToast | undefined>();
const [confirmPnpNotDiscoverable, setConfirmPnpNoDiscoverable] =
useState(false);
function closeLanguageDialog() { function closeLanguageDialog() {
setLanguageDialog(null); setLanguageDialog(null);
@ -1484,7 +1486,13 @@ export function Preferences({
title={i18n('icu:Preferences__pnp__discoverability--title')} title={i18n('icu:Preferences__pnp__discoverability--title')}
> >
<SettingsRadio <SettingsRadio
onChange={onWhoCanFindMeChange} onChange={value => {
if (value === PhoneNumberDiscoverability.NotDiscoverable) {
setConfirmPnpNoDiscoverable(true);
} else {
onWhoCanFindMeChange(value);
}
}}
options={[ options={[
{ {
text: i18n('icu:Preferences__pnp__discoverability__everyone'), text: i18n('icu:Preferences__pnp__discoverability__everyone'),
@ -1515,6 +1523,43 @@ export function Preferences({
</div> </div>
</div> </div>
</SettingsRow> </SettingsRow>
{confirmPnpNotDiscoverable && (
<ConfirmationDialog
i18n={i18n}
title={i18n(
'icu:Preferences__pnp__discoverability__nobody__confirmModal__title'
)}
dialogName="Preference.turnPnpDiscoveryOff"
onClose={() => {
setConfirmPnpNoDiscoverable(false);
}}
actions={[
{
action: () =>
onWhoCanFindMeChange(
PhoneNumberDiscoverability.NotDiscoverable
),
style: 'affirmative',
text: i18n('icu:ok'),
},
]}
>
{i18n(
'icu:Preferences__pnp__discoverability__nobody__confirmModal__description',
{
// This is a rare instance where we want to interpolate the exact
// text of the string into quotes in the translation as an
// explanation.
settingTitle: i18n(
'icu:Preferences__pnp__discoverability--title'
),
nobodyLabel: i18n(
'icu:Preferences__pnp__discoverability__nobody'
),
}
)}
</ConfirmationDialog>
)}
</> </>
); );
} }