Add trusted link handling in renderer/prompt

This commit is contained in:
Snazzah
2021-08-30 14:08:13 +00:00
committed by GitHub
parent 4c34787ef3
commit d8465b1aae
2 changed files with 42 additions and 13 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,6 +30,21 @@ 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: "Trust this domain",
}
]}>
<Text id={"app.special.modals.external_links.short"} /> <br />
<a>{link}</a>