Link guard working.

pull/1708/head
Warrick Corfe-Tan 4 years ago
parent 4776c6bd57
commit a9913d29f7

@ -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<Props> {
// disable click on <a> 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));
}
}))
};
}

Loading…
Cancel
Save