mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Merge pull request #1708 from warrickct/link-visit-confirmation
Link visit confirmation
This commit is contained in:
commit
bc3819aab7
2 changed files with 25 additions and 2 deletions
|
@ -419,5 +419,8 @@
|
|||
"device": "Device",
|
||||
"destination": "Destination",
|
||||
"learnMore": "Learn more",
|
||||
"playAtCustomSpeed": "Play at $multipler$x speed"
|
||||
"playAtCustomSpeed": "Play at $multipler$x speed",
|
||||
"linkVisitWarningTitle": "Open this link in your browser?",
|
||||
"linkVisitWarningMessage": "Are you sure you want to open $url$ in your browser?",
|
||||
"open": "Open"
|
||||
}
|
||||
|
|
|
@ -4,7 +4,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 +71,25 @@ 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 = () => {
|
||||
void shell.openExternal(url);
|
||||
};
|
||||
|
||||
window.inboxStore?.dispatch(
|
||||
updateConfirmModal({
|
||||
title: window.i18n('linkVisitWarningTitle'),
|
||||
message: window.i18n('linkVisitWarningMessage', url),
|
||||
okText: window.i18n('open'),
|
||||
onClickOk: openLink,
|
||||
onClickClose: () => {
|
||||
window.inboxStore?.dispatch(updateConfirmModal(null));
|
||||
},
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue