From e27e299f14fc0777c09c6d18d74e61b17dd61850 Mon Sep 17 00:00:00 2001 From: Warrick Corfe-Tan Date: Fri, 18 Jun 2021 16:18:51 +1000 Subject: [PATCH] minor refactor. --- .../conversation/SessionCompositionBox.tsx | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/ts/components/session/conversation/SessionCompositionBox.tsx b/ts/components/session/conversation/SessionCompositionBox.tsx index 88aec4ff2..ce315adcd 100644 --- a/ts/components/session/conversation/SessionCompositionBox.tsx +++ b/ts/components/session/conversation/SessionCompositionBox.tsx @@ -225,27 +225,7 @@ export class SessionCompositionBox extends React.Component { imgBlob = item.getAsFile(); break; case ('text'): - // check for links - console.log('is a text'); - let x = e.clipboardData.getData('text'); - console.log({ x }); - if (this.isURL(x)) { - console.log('IS A URL!'); - // const dispatch = useDispatch(); - // dispatch(updateConfirmModal({ - // shouldShowConfirm: () => !window.getSettingValue('link-preview-setting'), - // title: window.i18n('linkPreviewsTitle'), - // message: window.i18n('linkPreviewsConfirmMessage'), - // okTheme: SessionButtonColor.Danger, - // })) - this.props.updateConfirmModal({ - shouldShowConfirm: () => !window.getSettingValue('link-preview-setting'), - title: window.i18n('linkPreviewsTitle'), - message: window.i18n('linkPreviewsConfirmMessage'), - okTheme: SessionButtonColor.Danger, - }) - } - + this.showLinkSharingConfirmationModalDialog(e); } } if (imgBlob !== null) { @@ -258,6 +238,22 @@ export class SessionCompositionBox extends React.Component { } } + /** + * Check if what is pasted is a URL and prompt confirmation for a setting change + * @param e paste event + */ + private showLinkSharingConfirmationModalDialog(e: any) { + let pastedText = e.clipboardData.getData('text'); + if (this.isURL(pastedText)) { + this.props.updateConfirmModal({ + shouldShowConfirm: () => !window.getSettingValue('link-preview-setting'), + title: window.i18n('linkPreviewsTitle'), + message: window.i18n('linkPreviewsConfirmMessage'), + okTheme: SessionButtonColor.Danger, + }); + } + } + /** * * @param str String to evaluate