diff --git a/lib/core/viewer/components/viewer.component.ts b/lib/core/viewer/components/viewer.component.ts index 17f4b36d26..e0f08ecd40 100644 --- a/lib/core/viewer/components/viewer.component.ts +++ b/lib/core/viewer/components/viewer.component.ts @@ -175,7 +175,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy { * There is a delay of at least one second between attempts. */ @Input() - maxRetries = 5; + maxRetries = 10; /** Emitted when user clicks the 'Back' button. */ @Output() @@ -678,28 +678,31 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy { } private async waitRendition(nodeId: string, renditionId: string, retries: number): Promise { - + let currentRetry = 0; return new Promise((resolve, reject) => { let intervalId = setInterval(() => { - this.apiService.renditionsApi.getRendition(nodeId, renditionId).then((rendition) => { - const status = rendition.entry.status.toString(); - if (status === 'CREATED') { + currentRetry++; + if (this.maxRetries >= currentRetry) { + this.apiService.renditionsApi.getRendition(nodeId, renditionId).then((rendition) => { + const status = rendition.entry.status.toString(); + if (status === 'CREATED') { - if (renditionId === 'pdf') { - this.viewerType = 'pdf'; - } else if (renditionId === 'imgpreview') { - this.viewerType = 'image'; + if (renditionId === 'pdf') { + this.viewerType = 'pdf'; + } else if (renditionId === 'imgpreview') { + this.viewerType = 'image'; + } + + this.urlFileContent = this.apiService.contentApi.getRenditionUrl(nodeId, renditionId); + + clearInterval(intervalId); + return resolve(rendition); } - - this.urlFileContent = this.apiService.contentApi.getRenditionUrl(nodeId, renditionId); - - clearInterval(intervalId); - return resolve(rendition); - } - }, () => { - this.viewerType = 'error_in_creation'; - return reject(); - }); + }, () => { + this.viewerType = 'error_in_creation'; + return reject(); + }); + } }, 1000); }); }