Allow to copy an url on click on it via dialog

Relates #1842
This commit is contained in:
audric 2021-08-11 14:16:27 +10:00
parent b83067d0ee
commit 9018ae3009
2 changed files with 12 additions and 0 deletions

View File

@ -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<Props> {
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);
},
})
);
};

View File

@ -16,6 +16,7 @@ export interface SessionConfirmDialogProps {
onClose?: any;
onClickOk?: () => Promise<void> | 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();
}