feat(mobx): migrate trusted links

This commit is contained in:
Paul Makles
2021-12-17 10:20:55 +00:00
parent 120e6a35d8
commit 89dda8fe82
7 changed files with 57 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
import { Text } from "preact-i18n";
import { useApplicationState } from "../../../mobx/State";
import { dispatch } from "../../../redux";
import Modal from "../../../components/ui/Modal";
@@ -13,6 +14,7 @@ interface Props {
export function ExternalLinkModal({ onClose, link }: Props) {
const { openLink } = useIntermediate();
const settings = useApplicationState().settings;
return (
<Modal
@@ -39,13 +41,10 @@ export function ExternalLinkModal({ onClose, link }: Props) {
onClick: () => {
try {
const url = new URL(link);
dispatch({
type: "TRUSTED_LINKS_ADD_DOMAIN",
domain: url.hostname,
});
settings.security.addTrustedOrigin(url.hostname);
} catch (e) {}
openLink(link);
openLink(link, true);
onClose();
},
plain: true,