mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
fix issue where thumbnail would sometimes keep loading indefinitely
This commit is contained in:
@@ -97,13 +97,6 @@ export class ThumbnailComponent implements OnChanges {
|
||||
*/
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (isPlatformBrowser(this.platformID)) {
|
||||
// every time the inputs change we need to start the loading animation again, as it's possible
|
||||
// that thumbnail is first set to null when the parent component initializes and then set to
|
||||
// the actual value
|
||||
if (this.isLoading$.getValue() === false) {
|
||||
this.isLoading$.next(true);
|
||||
}
|
||||
|
||||
if (hasNoValue(this.thumbnail)) {
|
||||
this.setSrc(this.defaultImage);
|
||||
return;
|
||||
@@ -196,11 +189,24 @@ export class ThumbnailComponent implements OnChanges {
|
||||
* @param src
|
||||
*/
|
||||
setSrc(src: string): void {
|
||||
// only update the src if it has changed (the parent component may fire the same one multiple times
|
||||
if (this.src$.getValue() !== src) {
|
||||
// every time the src changes we need to start the loading animation again, as it's possible
|
||||
// that it is first set to null when the parent component initializes and then set to
|
||||
// the actual value
|
||||
//
|
||||
// isLoading$ will be set to false by the error or success handler afterwards, except in the
|
||||
// case where src is null, then we have to set it manually here (because those handlers won't
|
||||
// trigger)
|
||||
if (this.isLoading$.getValue() === false) {
|
||||
this.isLoading$.next(true);
|
||||
}
|
||||
this.src$.next(src);
|
||||
if (src === null) {
|
||||
this.isLoading$.next(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the loading animation once the thumbnail is successfully loaded
|
||||
|
Reference in New Issue
Block a user