From 8d255fc33154ba3e2489fdcbff72d10207b40fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Sat, 7 Apr 2018 23:22:55 -0400 Subject: [PATCH] Only bind preview "More" buttons on link previews --- client/js/renderPreview.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/client/js/renderPreview.js b/client/js/renderPreview.js index 083122e2..9598bd58 100644 --- a/client/js/renderPreview.js +++ b/client/js/renderPreview.js @@ -73,9 +73,8 @@ function appendPreview(preview, msg, template) { const previewContent = previewContainer.find(".toggle-content"); const showMoreIfNeeded = () => { - // Only applies on: - if (preview.type === "link" && // link previews - channel.hasClass("active") && // in the current channels + // Only applies on previews: + if (channel.hasClass("active") && // in the current channel previewContent.hasClass("show") // that are expanded ) { const isVisible = moreBtn.is(":visible"); @@ -90,12 +89,13 @@ function appendPreview(preview, msg, template) { } }; - $(window).on("resize", debounce(showMoreIfNeeded, 150)); - window.requestAnimationFrame(showMoreIfNeeded); - previewContent.on( - "showMoreIfNeeded", - () => window.requestAnimationFrame(showMoreIfNeeded) - ); + if (preview.type === "link") { + $(window).on("resize", debounce(showMoreIfNeeded, 150)); + window.requestAnimationFrame(showMoreIfNeeded); + previewContent.on("showMoreIfNeeded", + () => window.requestAnimationFrame(showMoreIfNeeded) + ); + } if (activeChannelId === channelId) { container.trigger("keepToBottom");