Mark link as trusted when opening, fixes #331.

This commit is contained in:
Paul 2021-10-10 16:11:43 +01:00
parent 40d95025b5
commit 14e749b65b
2 changed files with 4 additions and 3 deletions

View file

@ -106,7 +106,7 @@ export const IntermediateContext = createContext({
}); });
export const IntermediateActionsContext = createContext<{ export const IntermediateActionsContext = createContext<{
openLink: (href?: string) => boolean; openLink: (href?: string, trusted?: boolean) => boolean;
openScreen: (screen: Screen) => void; openScreen: (screen: Screen) => void;
writeClipboard: (text: string) => void; writeClipboard: (text: string) => void;
}>({ }>({
@ -130,7 +130,7 @@ export default function Intermediate(props: Props) {
const actions = useMemo(() => { const actions = useMemo(() => {
return { return {
openLink: (href?: string) => { openLink: (href?: string, trusted?: boolean) => {
const link = determineLink(href); const link = determineLink(href);
switch (link.type) { switch (link.type) {
@ -145,6 +145,7 @@ export default function Intermediate(props: Props) {
case "external": { case "external": {
const { trustedLinks } = getState(); const { trustedLinks } = getState();
if ( if (
!trusted &&
!trustedLinks.domains?.includes(link.url.hostname) !trustedLinks.domains?.includes(link.url.hostname)
) { ) {
openScreen({ openScreen({

View file

@ -22,7 +22,7 @@ export function ExternalLinkModal({ onClose, link }: Props) {
actions={[ actions={[
{ {
onClick: () => { onClick: () => {
openLink(link); openLink(link, true);
onClose(); onClose();
}, },
confirmation: true, confirmation: true,