From a9913d29f7a8f1fc9b24cf30ed2980c23dd87a71 Mon Sep 17 00:00:00 2001 From: Warrick Corfe-Tan Date: Mon, 21 Jun 2021 17:09:15 +1000 Subject: [PATCH] Link guard working. --- ts/components/conversation/Linkify.tsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ts/components/conversation/Linkify.tsx b/ts/components/conversation/Linkify.tsx index 630c4e43d..22187a3f5 100644 --- a/ts/components/conversation/Linkify.tsx +++ b/ts/components/conversation/Linkify.tsx @@ -5,6 +5,8 @@ import LinkifyIt from 'linkify-it'; import { RenderTextCallbackType } from '../../types/Util'; import { isLinkSneaky } from '../../../js/modules/link_previews'; import { SessionHtmlRenderer } from '../session/SessionHTMLRenderer'; +import { updateConfirmModal } from '../../state/ducks/modalDialog'; +import { shell } from 'electron'; const linkify = LinkifyIt(); @@ -70,6 +72,23 @@ export class Linkify extends React.Component { // disable click on elements so clicking a message containing a link doesn't // select the message.The link will still be opened in the browser. public handleClick = (e: any) => { + e.preventDefault(); e.stopPropagation(); + + const url = e.target.href; + + const openLink = () => { + // window.open(e.target.href); + void shell.openExternal(url); + } + + window.inboxStore?.dispatch(updateConfirmModal({ + title: "Hello", + message: "Are you sure you want to open this link?", + onClickOk: openLink, + onClickClose: () => { + window.inboxStore?.dispatch(updateConfirmModal(null)); + } + })) }; }