/* * Copyright (C) 2026 Fluxer Contributors * * This file is part of Fluxer. * * Fluxer is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Fluxer is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Fluxer. If not, see . */ import * as ModalActionCreators from '@app/actions/ModalActionCreators'; import * as TrustedDomainActionCreators from '@app/actions/TrustedDomainActionCreators'; import styles from '@app/components/modals/ExternalLinkWarningModal.module.css'; import * as Modal from '@app/components/modals/Modal'; import {Button} from '@app/components/uikit/button/Button'; import {Checkbox} from '@app/components/uikit/checkbox/Checkbox'; import {openExternalUrl} from '@app/utils/NativeUtils'; import {Trans, useLingui} from '@lingui/react/macro'; import {ArrowRightIcon, WarningIcon} from '@phosphor-icons/react'; import {observer} from 'mobx-react-lite'; import {useCallback, useMemo, useRef, useState} from 'react'; export const ExternalLinkWarningModal = observer(({url}: {url: string}) => { const {t} = useLingui(); const [trustDomain, setTrustDomain] = useState(false); const initialFocusRef = useRef(null); const hostname = useMemo(() => { try { return new URL(url).hostname; } catch { return url; } }, [url]); const handleContinue = useCallback(async () => { if (trustDomain) { await TrustedDomainActionCreators.addTrustedDomain(hostname); } void openExternalUrl(url); ModalActionCreators.pop(); }, [url, hostname, trustDomain]); const handleCancel = useCallback(() => { ModalActionCreators.pop(); }, []); const handleTrustChange = useCallback((checked: boolean) => { setTrustDomain(checked); }, []); const title = t`External Link Warning`; return (

You are about to leave Fluxer

External links can be dangerous. Please be careful.

Destination URL:

{url}

Always trust {hostname} — skip this warning next time
); });