If device signals fail, fall back to KWS
This commit is contained in:
@@ -384,8 +384,15 @@ function AccessSection() {
|
|||||||
const diff = lastInitiatedAt
|
const diff = lastInitiatedAt
|
||||||
? dateDiff(lastInitiatedAt, new Date(), 'down')
|
? dateDiff(lastInitiatedAt, new Date(), 'down')
|
||||||
: null
|
: null
|
||||||
const {onPressVerify, openInitDialog, isVerifying, verifyCta} =
|
const {
|
||||||
useAgeAssuranceVerificationFlow({initDialogControl: control})
|
onPressVerify,
|
||||||
|
openInitDialog,
|
||||||
|
isVerifying,
|
||||||
|
verifyCta,
|
||||||
|
deviceSignalsFailed,
|
||||||
|
} = useAgeAssuranceVerificationFlow({initDialogControl: control})
|
||||||
|
const useDeviceSignals =
|
||||||
|
aa.flags.allowsDeviceVerification && !deviceSignalsFailed
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -426,7 +433,7 @@ function AccessSection() {
|
|||||||
<ButtonText>{verifyCta}</ButtonText>
|
<ButtonText>{verifyCta}</ButtonText>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{aa.flags.allowsDeviceVerification ? (
|
{useDeviceSignals ? (
|
||||||
<Text
|
<Text
|
||||||
style={[a.text_sm, a.italic, t.atoms.text_contrast_medium]}>
|
style={[a.text_sm, a.italic, t.atoms.text_contrast_medium]}>
|
||||||
<Trans>
|
<Trans>
|
||||||
|
|||||||
@@ -46,13 +46,16 @@ export function useAgeAssuranceVerificationFlow({
|
|||||||
const aa = useAgeAssurance()
|
const aa = useAgeAssurance()
|
||||||
const hasInitiated = !!aa.state.lastInitiatedAt
|
const hasInitiated = !!aa.state.lastInitiatedAt
|
||||||
const allowsDeviceVerification = region && aa.flags.allowsDeviceVerification
|
const allowsDeviceVerification = region && aa.flags.allowsDeviceVerification
|
||||||
const verifyCta = allowsDeviceVerification
|
|
||||||
? l`Share age data`
|
|
||||||
: hasInitiated
|
|
||||||
? l`Verify again`
|
|
||||||
: l`Verify now`
|
|
||||||
|
|
||||||
const [isVerifying, setIsVerifying] = useState(false)
|
const [isVerifying, setIsVerifying] = useState(false)
|
||||||
|
const [deviceSignalsFailed, setDeviceSignalsFailed] = useState(false)
|
||||||
|
|
||||||
|
const verifyCta =
|
||||||
|
allowsDeviceVerification && !deviceSignalsFailed
|
||||||
|
? l`Share age data`
|
||||||
|
: hasInitiated
|
||||||
|
? l`Verify again`
|
||||||
|
: l`Verify now`
|
||||||
|
|
||||||
const openInitDialog = useCallback(() => {
|
const openInitDialog = useCallback(() => {
|
||||||
initDialogControl.open()
|
initDialogControl.open()
|
||||||
@@ -80,7 +83,7 @@ export function useAgeAssuranceVerificationFlow({
|
|||||||
* a response at all: `getDeviceSignals` handles its own errors and returns
|
* a response at all: `getDeviceSignals` handles its own errors and returns
|
||||||
* undefined (e.g. on web or failure).
|
* undefined (e.g. on web or failure).
|
||||||
*/
|
*/
|
||||||
if (allowsDeviceVerification) {
|
if (allowsDeviceVerification && !deviceSignalsFailed) {
|
||||||
// Show a loading state while the OS age prompt is up.
|
// Show a loading state while the OS age prompt is up.
|
||||||
setIsVerifying(true)
|
setIsVerifying(true)
|
||||||
let signals: AgeRange.AgeRangeResponse | undefined
|
let signals: AgeRange.AgeRangeResponse | undefined
|
||||||
@@ -131,6 +134,7 @@ export function useAgeAssuranceVerificationFlow({
|
|||||||
l`Hmm, it seems your device was unable to share age information with us.`,
|
l`Hmm, it seems your device was unable to share age information with us.`,
|
||||||
{type: 'warning'},
|
{type: 'warning'},
|
||||||
)
|
)
|
||||||
|
setDeviceSignalsFailed(true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logger.debug(
|
logger.debug(
|
||||||
@@ -146,6 +150,8 @@ export function useAgeAssuranceVerificationFlow({
|
|||||||
allowsDeviceVerification,
|
allowsDeviceVerification,
|
||||||
aa,
|
aa,
|
||||||
l,
|
l,
|
||||||
|
deviceSignalsFailed,
|
||||||
|
setDeviceSignalsFailed,
|
||||||
])
|
])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -153,5 +159,6 @@ export function useAgeAssuranceVerificationFlow({
|
|||||||
openInitDialog,
|
openInitDialog,
|
||||||
isVerifying,
|
isVerifying,
|
||||||
verifyCta,
|
verifyCta,
|
||||||
|
deviceSignalsFailed,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,8 +63,15 @@ function Inner({style}: ViewStyleProp & {}) {
|
|||||||
const diff = lastInitiatedAt
|
const diff = lastInitiatedAt
|
||||||
? dateDiff(lastInitiatedAt, new Date(), 'down')
|
? dateDiff(lastInitiatedAt, new Date(), 'down')
|
||||||
: null
|
: null
|
||||||
const {onPressVerify, openInitDialog, isVerifying, verifyCta} =
|
const {
|
||||||
useAgeAssuranceVerificationFlow({initDialogControl: control})
|
onPressVerify,
|
||||||
|
openInitDialog,
|
||||||
|
isVerifying,
|
||||||
|
verifyCta,
|
||||||
|
deviceSignalsFailed,
|
||||||
|
} = useAgeAssuranceVerificationFlow({initDialogControl: control})
|
||||||
|
const useDeviceSignals =
|
||||||
|
aa.flags.allowsDeviceVerification && !deviceSignalsFailed
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -156,7 +163,7 @@ function Inner({style}: ViewStyleProp & {}) {
|
|||||||
<ButtonText>{verifyCta}</ButtonText>
|
<ButtonText>{verifyCta}</ButtonText>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{aa.flags.allowsDeviceVerification ? (
|
{useDeviceSignals ? (
|
||||||
<Text
|
<Text
|
||||||
style={[a.text_sm, a.italic, t.atoms.text_contrast_medium]}>
|
style={[a.text_sm, a.italic, t.atoms.text_contrast_medium]}>
|
||||||
<Trans>
|
<Trans>
|
||||||
|
|||||||
Reference in New Issue
Block a user