fix: handle undefined error for pdf assetPreview (#442)

This commit is contained in:
stew-ro 2020-07-23 12:13:22 -07:00 коммит произвёл GitHub
Родитель 7fcc9ccfdb
Коммит f041bff977
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 11 добавлений и 12 удалений

Просмотреть файл

@ -181,25 +181,24 @@ export class PDFAsset extends React.Component<IAssetPreviewProps, IPDFAssetState
this.pendingRelease = true;
try {
if (this.renderTask) {
await this.renderTask.promise
await this.renderTask?.promise
this.renderTask = null;
}
if (this.loadingTask) {
await this.loadingTask.promise
await this.loadingTask?.promise
this.loadingTask = null;
}
if (this.pdf) {
await this.pdf?.cleanup();
await this.pdf?.destroy();
this.pdf = null;
}
if (this.canvas) {
delete this.canvas;
this.canvas = null;
}
} catch {
// do nothing on rejects
}
if (this.pdf) {
this.pdf.cleanup().then(() => {
this.pdf.destroy();
this.pdf = null;
});
}
if (this.canvas) {
delete this.canvas;
this.canvas = null;
}
}
}