From e69873d6ba9a06f73b1c81bf41c6153531cc3f81 Mon Sep 17 00:00:00 2001 From: audric Date: Fri, 23 Jul 2021 15:16:51 +1000 Subject: [PATCH 1/2] fix link preview url onClick Fixes https://github.com/oxen-io/session-android/issues/669 --- ts/session/messages/outgoing/visibleMessage/VisibleMessage.ts | 1 - ts/session/utils/Attachments.ts | 4 +--- ts/session/utils/AttachmentsV2.ts | 3 ++- ts/test/session/unit/messages/ChatMessage_test.ts | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ts/session/messages/outgoing/visibleMessage/VisibleMessage.ts b/ts/session/messages/outgoing/visibleMessage/VisibleMessage.ts index 21d3004ce..afa698028 100644 --- a/ts/session/messages/outgoing/visibleMessage/VisibleMessage.ts +++ b/ts/session/messages/outgoing/visibleMessage/VisibleMessage.ts @@ -38,7 +38,6 @@ export interface Preview { export interface PreviewWithAttachmentUrl { url: string; - id: number; title?: string; image?: AttachmentPointerWithUrl; } diff --git a/ts/session/utils/Attachments.ts b/ts/session/utils/Attachments.ts index 225d06536..547311956 100644 --- a/ts/session/utils/Attachments.ts +++ b/ts/session/utils/Attachments.ts @@ -22,7 +22,7 @@ interface UploadParams { } export interface RawPreview { - url?: string; + url: string; title?: string; image: Attachment; } @@ -129,8 +129,6 @@ export class AttachmentFsV2Utils { return { ...preview, image, - url: image.url, - id: image.id, }; }); return _.compact(await Promise.all(promises)); diff --git a/ts/session/utils/AttachmentsV2.ts b/ts/session/utils/AttachmentsV2.ts index d1783658c..5730efd9c 100644 --- a/ts/session/utils/AttachmentsV2.ts +++ b/ts/session/utils/AttachmentsV2.ts @@ -8,6 +8,7 @@ import { PreviewWithAttachmentUrl, Quote, QuotedAttachment, + QuotedAttachmentWithUrl, } from '../messages/outgoing/visibleMessage/VisibleMessage'; import { uploadFileOpenGroupV2 } from '../../opengroup/opengroupV2/OpenGroupAPIV2'; import { addAttachmentPadding } from '../crypto/BufferPadding'; @@ -105,7 +106,7 @@ export async function uploadQuoteThumbnailsV2( } const promises = (quote.attachments ?? []).map(async attachment => { - let thumbnail: PreviewWithAttachmentUrl | undefined; + let thumbnail: QuotedAttachment | undefined; if (attachment.thumbnail) { thumbnail = await exports.uploadV2({ attachment: attachment.thumbnail, diff --git a/ts/test/session/unit/messages/ChatMessage_test.ts b/ts/test/session/unit/messages/ChatMessage_test.ts index e2b3c4b5e..88e20adfd 100644 --- a/ts/test/session/unit/messages/ChatMessage_test.ts +++ b/ts/test/session/unit/messages/ChatMessage_test.ts @@ -88,7 +88,7 @@ describe('VisibleMessage', () => { it('can create message with a preview', () => { let preview: PreviewWithAttachmentUrl; - preview = { url: 'url', title: 'title', id: 1234 }; + preview = { url: 'url', title: 'title' }; const previews = new Array(); previews.push(preview); From e82d51fff08d03463e07acb13f1ebb634a12d1d6 Mon Sep 17 00:00:00 2001 From: audric Date: Fri, 23 Jul 2021 15:21:51 +1000 Subject: [PATCH 2/2] do not show warning about link preview if they are already ON --- ts/components/session/conversation/SessionCompositionBox.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/components/session/conversation/SessionCompositionBox.tsx b/ts/components/session/conversation/SessionCompositionBox.tsx index 8352e0ca1..68c6d1a98 100644 --- a/ts/components/session/conversation/SessionCompositionBox.tsx +++ b/ts/components/session/conversation/SessionCompositionBox.tsx @@ -239,7 +239,7 @@ class SessionCompositionBoxInner extends React.Component { */ private async showLinkSharingConfirmationModalDialog(e: any) { const pastedText = e.clipboardData.getData('text'); - if (this.isURL(pastedText)) { + if (this.isURL(pastedText) && !window.getSettingValue('link-preview-setting', false)) { const alreadyDisplayedPopup = (await getItemById(hasLinkPreviewPopupBeenDisplayed))?.value || false; window.inboxStore?.dispatch(