-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] Image attachment re-renders on message update #14207
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
onDestroy
function 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.onDestroy
call that stores the value ofloaded
state before being destroyed because of the update in the message. So whenever the template is recreated, nowthis.loaded
has the same state as what was before updating a message(or being destroyed).