From 0d7480bd9222c6496da00494b37f4f3eff528e35 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Thu, 31 Jan 2019 09:53:11 -0800 Subject: [PATCH] A number of small fixes for Link Previews --- _locales/en/messages.json | 11 ----------- js/models/conversations.js | 4 +++- js/models/messages.js | 2 +- js/modules/link_previews.js | 2 +- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index f8a3a0465..df5d1a8e6 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1076,17 +1076,6 @@ "message": "General", "description": "Header for general options on the settings screen" }, - "sendLinkPreviews": { - "message": "Send Link Previews", - "description": - "Option to control creation and send of link previews in setting screen" - }, - "linkPreviewsDescription": { - "message": - "Previews are supported for Imgur, Instagram, Reddit, and YouTube links.", - "description": - "Additional detail provided for Link Previews option in settings screen" - }, "spellCheckDescription": { "message": "Enable spell check of text entered in message composition box", "description": "Description of the media permission description" diff --git a/js/models/conversations.js b/js/models/conversations.js index 0a689f585..580bb7a1c 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -779,8 +779,10 @@ media .filter( attachment => - (attachment && attachment.thumbnail) || attachment.message + attachment && + (attachment.image || (!attachment.pending && !attachment.error)) ) + .slice(0, 1) .map(async attachment => { const { fileName } = attachment; diff --git a/js/models/messages.js b/js/models/messages.js index 8c118df8a..66fbe5e78 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -1182,7 +1182,7 @@ urls.includes(item.url) && window.Signal.LinkPreviews.isLinkInWhitelist(item.url) ); - if (preview.length > incomingPreview.length) { + if (preview.length < incomingPreview.length) { window.log.info( `${message.idForLogging()}: Eliminated ${preview.length - incomingPreview.length} previews with invalid urls'` diff --git a/js/modules/link_previews.js b/js/modules/link_previews.js index 990b88f91..3c3f7c5a7 100644 --- a/js/modules/link_previews.js +++ b/js/modules/link_previews.js @@ -55,7 +55,7 @@ function isLinkInWhitelist(link) { } } -const SUPPORTED_MEDIA_DOMAINS = /^([^.]+\.)*(ytimg.com|cdninstagram.com|redd.it|imgur.com)$/i; +const SUPPORTED_MEDIA_DOMAINS = /^([^.]+\.)*(ytimg.com|cdninstagram.com|redd.it|imgur.com|fbcdn.net)$/i; function isMediaLinkInWhitelist(link) { try { const url = new URL(link);