aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/pdf/PDFViewer.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/pdf/PDFViewer.tsx')
-rw-r--r--src/client/views/pdf/PDFViewer.tsx14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index 516774f44..50ffd57fe 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -111,6 +111,7 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu
private _downX: number = 0;
private _downY: number = 0;
private _coverPath: any;
+ private _viewerIsSetup = false;
@computed get allAnnotations() {
return DocListCast(this.dataDoc[this.props.fieldKey + "-annotations"]).filter(
@@ -160,7 +161,14 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu
}, { fireImmediately: true });
this._selectionReactionDisposer = reaction(() => this.props.isSelected(),
- () => (SelectionManager.SelectedDocuments().length === 1) && this.setupPdfJsViewer(),
+ selected => {
+ if (!selected) {
+ this._savedAnnotations.values().forEach(v => v.forEach(a => a.remove()));
+ this._savedAnnotations.keys().forEach(k => this._savedAnnotations.setValue(k, []));
+ PDFMenu.Instance.fadeOut(true);
+ }
+ (SelectionManager.SelectedDocuments().length === 1) && this.setupPdfJsViewer();
+ },
{ fireImmediately: true });
this._reactionDisposer = reaction(
() => this.Document._scrollY,
@@ -216,8 +224,8 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu
@action
setupPdfJsViewer = async () => {
- this._selectionReactionDisposer && this._selectionReactionDisposer();
- this._selectionReactionDisposer = undefined;
+ if (this._viewerIsSetup) return;
+ else this._viewerIsSetup = true;
this._showWaiting = true;
this.props.setPdfViewer(this);
await this.initialLoad();