rpaschoal / ng-chat

💬 A simple facebook/linkedin lookalike chat module for Angular applications.
MIT License
155 stars 92 forks source link

Avatar images are loading again and again on each Application changeDetection #134

Closed Vartld closed 4 years ago

Vartld commented 4 years ago

Hi, first of all thank you for an amazing package!

We have faced the problem, while using your package in development of the chat feature for our application.

The problem is this:

We put a link for avatar image for each participant in chat adapter. Then we payed attention, that on every Angular change detection, the avatar images are loaded again: image

We checked the package code and found that [src]="sanitizer.bypassSecurityTrustResourceUrl(user.avatar)" [src]="sanitizer.bypassSecurityTrustResourceUrl(getChatWindowAvatar(window.participant, message))" in the \node_modules\ng-chat\fesm5 line 1525, are the strings, that are causing this problem.

To be more particular, it is sanitizer.bypassSecurityTrustResourceUrl function of the DomSanitizer.

We found out, if we allow Dom sanitation, by removing that function, everything works fine: [src]="user.avatar" [src]="getChatWindowAvatar(window.participant, message)"

Could you please deal with this issue, and let us know when it is solved.

Thank you, and best regards, AirsoftLtd development team.

rpaschoal commented 4 years ago

Hi @victorz-airsoft ,

This was added as a request by another user long time ago. I believe the sanitizer is helpful when the resources are coming from a different domain then the running application itself. I'll make this a configuration and leave it off by default which should fix your issue. I'm planning a patch release with small bug fixes soon so keep an eye on this.

Cheers

Vartld commented 4 years ago

Hi Rafael, thank you for the quick reply.

Making it configuration for users choice is great solution for this.

Thank you and best regards

From: Rafael Carvalho notifications@github.com Sent: Saturday, August 24, 2019 12:21 AM To: rpaschoal/ng-chat ng-chat@noreply.github.com Cc: victorz-airsoft victorz@airsoftltd.com; Mention mention@noreply.github.com Subject: Re: [rpaschoal/ng-chat] Avatar images are loading again and again on each Application changeDetection (#134)

Hi @victorz-airsoft https://github.com/victorz-airsoft ,

This was added as a request by another user long time ago. I believe the sanitizer is helpful when the resources are coming from a different domain then the running application itself. I'll make this a configuration and leave it off by default which should fix your issue. I'm planning a patch release with small bug fixes soon so keep an eye on this.

Cheers

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rpaschoal/ng-chat/issues/134?email_source=notifications&email_token=AM7J7TA637NG5UJFCL6K5F3QGBIE3A5CNFSM4IO5OK62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5BLQ7I#issuecomment-524466301 , or mute the thread https://github.com/notifications/unsubscribe-auth/AM7J7THV4PJBXGW3273BKB3QGBIE3ANCNFSM4IO5OK6Q .

rpaschoal commented 4 years ago

This should now be fixed with version 2.0.5: https://github.com/rpaschoal/ng-chat/releases/tag/2.0.5 👍