From 9018ae30093e94e369dba7b3664629245a2a4b28 Mon Sep 17 00:00:00 2001 From: audric Date: Wed, 11 Aug 2021 14:16:27 +1000 Subject: [PATCH] Allow to copy an url on click on it via dialog Relates #1842 --- ts/components/conversation/Linkify.tsx | 6 ++++++ ts/components/dialog/SessionConfirm.tsx | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/ts/components/conversation/Linkify.tsx b/ts/components/conversation/Linkify.tsx index 86658f1ab..6353cef6e 100644 --- a/ts/components/conversation/Linkify.tsx +++ b/ts/components/conversation/Linkify.tsx @@ -6,6 +6,7 @@ import { RenderTextCallbackType } from '../../types/Util'; import { isLinkSneaky } from '../../../js/modules/link_previews'; import { updateConfirmModal } from '../../state/ducks/modalDialog'; import { shell } from 'electron'; +import { MessageInteraction } from '../../interactions'; const linkify = LinkifyIt(); @@ -85,10 +86,15 @@ export class Linkify extends React.Component { title: window.i18n('linkVisitWarningTitle'), message: window.i18n('linkVisitWarningMessage', url), okText: window.i18n('open'), + cancelText: window.i18n('copy'), onClickOk: openLink, onClickClose: () => { window.inboxStore?.dispatch(updateConfirmModal(null)); }, + + onClickCancel: () => { + MessageInteraction.copyBodyToClipboard(url); + }, }) ); }; diff --git a/ts/components/dialog/SessionConfirm.tsx b/ts/components/dialog/SessionConfirm.tsx index 8f5e0d529..c938b16c3 100644 --- a/ts/components/dialog/SessionConfirm.tsx +++ b/ts/components/dialog/SessionConfirm.tsx @@ -16,6 +16,7 @@ export interface SessionConfirmDialogProps { onClose?: any; onClickOk?: () => Promise | void; onClickClose?: () => any; + onClickCancel?: () => any; okText?: string; cancelText?: string; hideCancel?: boolean; @@ -40,6 +41,7 @@ const SessionConfirmInner = (props: SessionConfirmDialogProps) => { sessionIcon, iconSize, shouldShowConfirm, + onClickCancel, } = props; const [isLoading, setIsLoading] = useState(false); @@ -75,6 +77,10 @@ const SessionConfirmInner = (props: SessionConfirmDialogProps) => { * Performs specified on close action then removes the modal. */ const onClickCancelHandler = () => { + if (onClickCancel) { + onClickCancel(); + } + if (onClickClose) { onClickClose(); }