@@ -95,13 +95,6 @@ export class ThumbnailComponent implements OnChanges {
9595 */
9696 ngOnChanges ( changes : SimpleChanges ) : void {
9797 if ( isPlatformBrowser ( this . platformID ) ) {
98- // every time the inputs change we need to start the loading animation again, as it's possible
99- // that thumbnail is first set to null when the parent component initializes and then set to
100- // the actual value
101- if ( ! this . isLoading ( ) ) {
102- this . isLoading . set ( true ) ;
103- }
104-
10598 if ( hasNoValue ( this . thumbnail ) ) {
10699 this . setSrc ( this . defaultImage ) ;
107100 return ;
@@ -194,9 +187,22 @@ export class ThumbnailComponent implements OnChanges {
194187 * @param src
195188 */
196189 setSrc ( src : string ) : void {
197- this . src . set ( src ) ;
198- if ( src === null ) {
199- this . isLoading . set ( false ) ;
190+ // only update the src if it has changed (the parent component may fire the same one multiple times
191+ if ( this . src ( ) !== src ) {
192+ // every time the src changes we need to start the loading animation again, as it's possible
193+ // that it is first set to null when the parent component initializes and then set to
194+ // the actual value
195+ //
196+ // isLoading$ will be set to false by the error or success handler afterwards, except in the
197+ // case where src is null, then we have to set it manually here (because those handlers won't
198+ // trigger)
199+ if ( this . isLoading ( ) === false ) {
200+ this . isLoading . set ( true ) ;
201+ }
202+ this . src . set ( src ) ;
203+ if ( src === null ) {
204+ this . isLoading . set ( false ) ;
205+ }
200206 }
201207 }
202208
0 commit comments