add link warning interstitial

This commit is contained in:
Samuel Newman
2026-02-11 13:14:27 +02:00
parent 5010d87575
commit c5f68d01af
2 changed files with 60 additions and 17 deletions
+15
View File
@@ -27,6 +27,21 @@ export function LinkWarningDialog() {
) )
} }
export function CustomLinkWarningDialog({
control,
link,
}: {
control: Dialog.DialogControlProps
link?: {href: string; displayText: string; share?: boolean}
}) {
return (
<Dialog.Outer control={control} nativeOptions={{preventExpansion: true}}>
<Dialog.Handle />
<LinkWarningDialogInner link={link} />
</Dialog.Outer>
)
}
function LinkWarningDialogInner({ function LinkWarningDialogInner({
link, link,
}: { }: {
@@ -17,6 +17,7 @@ import {useAgent, useSession} from '#/state/session'
import {atoms as a, useTheme, web} from '#/alf' import {atoms as a, useTheme, web} from '#/alf'
import {Button, ButtonIcon, ButtonText} from '#/components/Button' import {Button, ButtonIcon, ButtonText} from '#/components/Button'
import * as Dialog from '#/components/Dialog' import * as Dialog from '#/components/Dialog'
import {CustomLinkWarningDialog} from '#/components/dialogs/LinkWarning'
import {ArrowTopRight_Stroke2_Corner0_Rounded as ArrowTopRightIcon} from '#/components/icons/Arrow' import {ArrowTopRight_Stroke2_Corner0_Rounded as ArrowTopRightIcon} from '#/components/icons/Arrow'
import {Link} from '#/components/Link' import {Link} from '#/components/Link'
import {Loader} from '#/components/Loader' import {Loader} from '#/components/Loader'
@@ -34,6 +35,7 @@ export function GermButton({
const {_} = useLingui() const {_} = useLingui()
const t = useTheme() const t = useTheme()
const {currentAccount} = useSession() const {currentAccount} = useSession()
const linkWarningControl = Dialog.useDialogControl()
// exclude `none` and all unknown values // exclude `none` and all unknown values
if ( if (
@@ -57,8 +59,16 @@ export function GermButton({
} }
return ( return (
<>
<Link <Link
to={url} to={url}
onPress={evt => {
if (isCustomGermDomain(url)) {
evt.preventDefault()
linkWarningControl.open()
return false
}
}}
label={_(msg`Open Germ DM`)} label={_(msg`Open Germ DM`)}
overridePresentation={false} overridePresentation={false}
shouldProxy={false} shouldProxy={false}
@@ -74,6 +84,15 @@ export function GermButton({
</Text> </Text>
<ArrowTopRightIcon style={[t.atoms.text, a.mx_2xs]} width={14} /> <ArrowTopRightIcon style={[t.atoms.text, a.mx_2xs]} width={14} />
</Link> </Link>
<CustomLinkWarningDialog
control={linkWarningControl}
link={{
href: url,
displayText: '',
share: false,
}}
/>
</>
) )
} }
@@ -251,6 +270,15 @@ function constructGermUrl(
} }
} }
function isCustomGermDomain(url: string) {
try {
const urlp = new URL(url)
return urlp.hostname !== 'landing.ger.mx'
} catch {
return false
}
}
function platform() { function platform() {
switch (Platform.OS) { switch (Platform.OS) {
case 'ios': case 'ios':