[FIX] Image attachment re-renders on message update#14207
[FIX] Image attachment re-renders on message update#14207rodrigok merged 2 commits intoRocketChat:developfrom
Conversation
|
@RocketChat/core if this solves... this would be amazing to include. An extremely annoying issue |
|
Does this work for others? Like say youtube embed? |
No, it doesn't because youtube embed doesn't depend upon lazyloadImage package. But I guess the strategy would be the same there too. |
|
@Kailash0311 Ok, but with your solution ALL images will share the same control variable right? Doesn't that defeats the purpose? |
|
A possible solution may be creating a |
|
To be clear, this will not stop the re render @geekgonecrazy , will just prevent the render of the preview/base64 image and then the original image, so it may blink less, but videos would back to the initial state due to the re render. To solve that we need to remove NRR or move to another template language, |
|
Ah! So this is only preventing the blury base64 to regular. Since the other image is already downloaded it re-renders fast enough you don't notice it. Drats.. I was hoping solving it really was this simple as its an extremely annoying issue. Avoiding the blurry to clear flicker still would be a welcome change though |
Oh, yes. How could I not see that! That is why new images were never loading the preview image. |
@rodrigok Do you mean using set method in Session package that meteor provides? Or a normal array of objects? |
Yes, this will not stop re-render as the message itself is being re-rendered altogether. This will just skip the loading of the preview image and directly load the main image. |
rodrigok
left a comment
There was a problem hiding this comment.
With this changes ALL images will share the same control variable.
Yes, I understood it. |
51e688c to
67a2836
Compare
|
@rodrigok In the recent changes, the PREVIEW image will not be re-loaded when the message is re-rendered. |
Closes #5028 and #14092
Issue and research: On researching and playing around with codebase a bit I found out that message is re-created everytime someone updates the message, (e.g: Starring or adding a reaction as mentioned in the issues that this PR solves.)Since it is meteor's default reactivity system because of which it is happening, my resolution is a simple work-around.
Resolution: Add a
onDestroyfunction to the lazyloadtemplate(This template is responsible for showing the preview of the attachment.) This template gets destroyed and recreated whenever there is some update in the message (e.g: Starring or adding a reaction). Workaround is a simpleTemplate.onDestroycall that stores the value ofloadedstate before being destroyed because of the update in the message. So whenever the template is recreated, nowthis.loadedhas the same state as what was before updating a message(or being destroyed).