@@ -74,13 +74,6 @@ export class ThumbnailComponent implements OnChanges {
7474 */
7575 ngOnChanges ( changes : SimpleChanges ) : void {
7676 if ( isPlatformBrowser ( this . platformID ) ) {
77- // every time the inputs change we need to start the loading animation again, as it's possible
78- // that thumbnail is first set to null when the parent component initializes and then set to
79- // the actual value
80- if ( this . isLoading$ . getValue ( ) === false ) {
81- this . isLoading$ . next ( true ) ;
82- }
83-
8477 if ( hasNoValue ( this . thumbnail ) ) {
8578 this . setSrc ( this . defaultImage ) ;
8679 return ;
@@ -173,9 +166,22 @@ export class ThumbnailComponent implements OnChanges {
173166 * @param src
174167 */
175168 setSrc ( src : string ) : void {
176- this . src$ . next ( src ) ;
177- if ( src === null ) {
178- this . isLoading$ . next ( false ) ;
169+ // only update the src if it has changed (the parent component may fire the same one multiple times
170+ if ( this . src$ . getValue ( ) !== src ) {
171+ // every time the src changes we need to start the loading animation again, as it's possible
172+ // that it is first set to null when the parent component initializes and then set to
173+ // the actual value
174+ //
175+ // isLoading$ will be set to false by the error or success handler afterwards, except in the
176+ // case where src is null, then we have to set it manually here (because those handlers won't
177+ // trigger)
178+ if ( this . isLoading$ . getValue ( ) === false ) {
179+ this . isLoading$ . next ( true ) ;
180+ }
181+ this . src$ . next ( src ) ;
182+ if ( src === null ) {
183+ this . isLoading$ . next ( false ) ;
184+ }
179185 }
180186 }
181187
0 commit comments