diff options
Diffstat (limited to 'src/client/views/nodes/PDFBox.tsx')
-rw-r--r-- | src/client/views/nodes/PDFBox.tsx | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx index 596975062..7ef431885 100644 --- a/src/client/views/nodes/PDFBox.tsx +++ b/src/client/views/nodes/PDFBox.tsx @@ -175,28 +175,26 @@ export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps>() { updateIcon = () => { // currently we render pdf icons as text labels const docViewContent = this.DocumentView?.().ContentDiv; - const filename = this.layoutDoc[Id] + '-icon' + new Date().getTime(); - this._pdfViewer?._mainCont.current && - docViewContent && - UpdateIcon( - filename, - docViewContent, - NumCast(this.layoutDoc._width), - NumCast(this.layoutDoc._height), - this._props.PanelWidth(), - this._props.PanelHeight(), - NumCast(this.layoutDoc._layout_scrollTop), - NumCast(this.dataDoc[this.fieldKey + '_nativeHeight'], 1), - true, - this.layoutDoc[Id] + '-icon', - (iconFile: string, nativeWidth: number, nativeHeight: number) => { - setTimeout(() => { - this.dataDoc.icon = new ImageField(iconFile); - this.dataDoc.icon_nativeWidth = nativeWidth; - this.dataDoc.icon_nativeHeight = nativeHeight; - }, 500); - } - ); + const filename = this.layoutDoc[Id] + '_icon_' + new Date().getTime(); + return !(this._pdfViewer?._mainCont.current && docViewContent) + ? new Promise<void>(res => res()) + : UpdateIcon( + filename, + docViewContent, + NumCast(this.layoutDoc._width), + NumCast(this.layoutDoc._height), + this._props.PanelWidth(), + this._props.PanelHeight(), + NumCast(this.layoutDoc._layout_scrollTop), + NumCast(this.dataDoc[this.fieldKey + '_nativeHeight'], 1), + true, + this.layoutDoc[Id] + '_icon_' + new Date().getTime(), + (iconFile: string, nativeWidth: number, nativeHeight: number) => { + this.dataDoc.icon = new ImageField(iconFile); + this.dataDoc.icon_nativeWidth = nativeWidth; + this.dataDoc.icon_nativeHeight = nativeHeight; + } + ); }; componentWillUnmount() { |