From bfa76b05d29dbb97683ba87818cd9b3d2f6d9f61 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Wed, 22 Jan 2020 11:34:36 -0800 Subject: [PATCH] No propagate, fix 'attachment save' cancel * Quote: Ensure that clicks don't propagate to parent * Attachment Save: Check for null; returned if user cancels out --- js/views/conversation_view.js | 15 ++++++++++++--- ts/components/conversation/Quote.tsx | 11 ++++++++++- ts/types/Attachment.ts | 10 +++++++--- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index 74e485eb68..3666cd2f38 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -1804,7 +1804,10 @@ saveAttachmentToDisk, timestamp, }); - this.showToast(Whisper.FileSavedToast, { fullPath }); + + if (fullPath) { + this.showToast(Whisper.FileSavedToast, { fullPath }); + } }; const onItemClick = async ({ message, attachment, type }) => { @@ -2001,7 +2004,10 @@ saveAttachmentToDisk, timestamp, }); - this.showToast(Whisper.FileSavedToast, { fullPath }); + + if (fullPath) { + this.showToast(Whisper.FileSavedToast, { fullPath }); + } }, async displayTapToViewMessage(messageId) { @@ -2205,7 +2211,10 @@ saveAttachmentToDisk, timestamp: options.message.get('sent_at'), }); - this.showToast(Whisper.FileSavedToast, { fullPath }); + + if (fullPath) { + this.showToast(Whisper.FileSavedToast, { fullPath }); + } }; const props = { diff --git a/ts/components/conversation/Quote.tsx b/ts/components/conversation/Quote.tsx index 0f1ea3815f..0485f1a1b2 100644 --- a/ts/components/conversation/Quote.tsx +++ b/ts/components/conversation/Quote.tsx @@ -105,6 +105,15 @@ export class Quote extends React.Component { onClick(); } }; + public handleClick = (event: React.MouseEvent) => { + const { onClick } = this.props; + + if (onClick) { + event.preventDefault(); + event.stopPropagation(); + onClick(); + } + }; public handleImageError = () => { // tslint:disable-next-line no-console @@ -381,7 +390,7 @@ export class Quote extends React.Component { )} >