Skip to content

Commit

Permalink
[FIX] image attachment re-render on message update (#14207)
Browse files Browse the repository at this point in the history
[FIX] Image attachment re-renders on message update
  • Loading branch information
Kailash0311 authored and rodrigok committed Apr 25, 2019
1 parent 5362e0e commit 12741f2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/lazy-load/client/lazyloadImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { addImage } from '.';
const emptyImageEncoded =
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8+/u3PQAJJAM0dIyWdgAAAABJRU5ErkJggg==';

const imgsrcs = new Set();

Template.lazyloadImage.helpers({
class() {
const loaded = Template.instance().loaded.get();
Expand All @@ -18,11 +20,11 @@ Template.lazyloadImage.helpers({

lazySrcUrl() {
const { preview, placeholder, src } = this;

if (Template.instance().loaded.get() || (!preview && !placeholder)) {
if (Template.instance().loaded.get() || (!preview && !placeholder) || imgsrcs.has(src)) {
return src;
}

imgsrcs.add(this.src);
return `data:image/png;base64,${ preview || emptyImageEncoded }`;
},
});
Expand Down

0 comments on commit 12741f2

Please sign in to comment.