From 99f862dd0f94d0ec65941126206e6cc3e511d10a Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Fri, 30 Jul 2021 08:51:17 +1000 Subject: [PATCH] fix send link preview keep being shown Relates #1810 --- .../conversation/SessionCompositionBox.tsx | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/ts/components/session/conversation/SessionCompositionBox.tsx b/ts/components/session/conversation/SessionCompositionBox.tsx index 68c6d1a98..0f6c83c91 100644 --- a/ts/components/session/conversation/SessionCompositionBox.tsx +++ b/ts/components/session/conversation/SessionCompositionBox.tsx @@ -242,21 +242,23 @@ class SessionCompositionBoxInner extends React.Component { if (this.isURL(pastedText) && !window.getSettingValue('link-preview-setting', false)) { const alreadyDisplayedPopup = (await getItemById(hasLinkPreviewPopupBeenDisplayed))?.value || false; - window.inboxStore?.dispatch( - updateConfirmModal({ - shouldShowConfirm: - !window.getSettingValue('link-preview-setting') && !alreadyDisplayedPopup, - title: window.i18n('linkPreviewsTitle'), - message: window.i18n('linkPreviewsConfirmMessage'), - okTheme: SessionButtonColor.Danger, - onClickOk: () => { - window.setSettingValue('link-preview-setting', true); - }, - onClickClose: async () => { - await createOrUpdateItem({ id: hasLinkPreviewPopupBeenDisplayed, value: true }); - }, - }) - ); + if (!alreadyDisplayedPopup) { + window.inboxStore?.dispatch( + updateConfirmModal({ + shouldShowConfirm: + !window.getSettingValue('link-preview-setting') && !alreadyDisplayedPopup, + title: window.i18n('linkPreviewsTitle'), + message: window.i18n('linkPreviewsConfirmMessage'), + okTheme: SessionButtonColor.Danger, + onClickOk: () => { + window.setSettingValue('link-preview-setting', true); + }, + onClickClose: async () => { + await createOrUpdateItem({ id: hasLinkPreviewPopupBeenDisplayed, value: true }); + }, + }) + ); + } } }