Merge pull request #158 from Snazzah/trusted-links

This commit is contained in:
Paul Makles
2021-09-03 11:18:16 +01:00
committed by GitHub
5 changed files with 87 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
import { Text } from "preact-i18n";
import Modal from "../../../components/ui/Modal";
import { dispatch } from "../../../redux";
interface Props {
onClose: () => void;
@@ -29,8 +30,23 @@ export function ExternalLinkModal({ onClose, link }: Props) {
confirmation: false,
children: "Cancel",
},
{
onClick: () => {
try {
const url = new URL(link);
dispatch({
type: "TRUSTED_LINKS_ADD_DOMAIN",
domain: url.hostname
});
} catch(e) {}
window.open(link, "_blank");
onClose();
},
plain: true,
children: <Text id="app.special.modals.external_links.trust_domain" />,
}
]}>
<Text id={"app.special.modals.external_links.short"} /> <br />
<Text id="app.special.modals.external_links.short" /> <br />
<a>{link}</a>
</Modal>
);