From 47eec14bca2a747cdd146af74b54132c10fde1ad Mon Sep 17 00:00:00 2001
From: chylex <contact@chylex.com>
Date: Fri, 4 May 2018 21:07:33 +0200
Subject: [PATCH] Fix freshly broken GIF previews in notifications

---
 Resources/Scripts/code.js | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/Resources/Scripts/code.js b/Resources/Scripts/code.js
index 25a835b4..dfdea8fd 100644
--- a/Resources/Scripts/code.js
+++ b/Resources/Scripts/code.js
@@ -146,7 +146,7 @@
     };
     
     let fixMedia = (html, media) => {
-      return html.find(".js-media a[data-media-entity-id='"+media.mediaId+"']").css("background-image", 'url("'+media.small()+'")').removeClass("is-zoomable");
+      return html.find("a[data-media-entity-id='"+media.mediaId+"'], .media-item").first().removeClass("is-zoomable").css("background-image", 'url("'+media.small()+'")');
     };
     
     return function(column, tweet){
@@ -181,13 +181,15 @@
         if (previews){
           html.find(".reverse-image-search").remove();
           
+          let container = html.find(".js-media");
+          
           for(let media of tweet.getMedia()){
-            fixMedia(html, media);
+            fixMedia(container, media);
           }
           
           if (tweet.quotedTweet){
             for(let media of tweet.quotedTweet.getMedia()){
-              fixMedia(html, media).addClass("media-size-medium");
+              fixMedia(container, media).addClass("media-size-medium");
             }
           }
         }