aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionSubView.tsx
diff options
context:
space:
mode:
authorMelissa Zhang <mzhang19096@gmail.com>2020-08-04 16:53:36 -0700
committerMelissa Zhang <mzhang19096@gmail.com>2020-08-04 16:53:36 -0700
commitbd6b5a81480f7f56a65c13954e080281279b6627 (patch)
tree531b168ea67f982c4ec65e39159a8a6e32ad7fd4 /src/client/views/collections/CollectionSubView.tsx
parente9737412cb3d60ed76c31c9571e9516518cddd77 (diff)
"added invisibleDoc and simulated clicks to load annotations"
Diffstat (limited to 'src/client/views/collections/CollectionSubView.tsx')
-rw-r--r--src/client/views/collections/CollectionSubView.tsx26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 5906282f1..b66da27b4 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -346,15 +346,22 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
// }
}
if (uriList) {
- this.addDocument(Docs.Create.WebDocument(uriList, {
- ...options,
- title: uriList,
- _width: 400,
- _height: 315,
- _nativeWidth: 850,
- _nativeHeight: 962,
- UseCors: true
- }));
+ const existingWebDoc = await Hypothesis.findWebDoc(uriList);
+
+ if (existingWebDoc) {
+ this.addDocument(Doc.MakeAlias(existingWebDoc));
+ } else {
+ const cleanedUri = uriList.split("#annotations:")[0]; // clean hypothes.is URLs that scroll directly to an annotation
+ this.addDocument(Docs.Create.WebDocument(uriList, {
+ ...options,
+ title: cleanedUri,
+ _width: 400,
+ // _height: 315,
+ _nativeWidth: 850,
+ _nativeHeight: 962,
+ UseCors: true
+ }));
+ }
return;
}
@@ -437,4 +444,5 @@ import { CollectionView, CollectionViewType } from "./CollectionView";
import { SelectionManager } from "../../util/SelectionManager";
import { OverlayView } from "../OverlayView";
import { setTimeout } from "timers";
+import { Hypothesis } from "../../apis/hypothesis/HypothesisUtils";