aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/DocumentManager.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/util/DocumentManager.ts')
-rw-r--r--src/client/util/DocumentManager.ts15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index 2ca29cb7e..4becdf4a3 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -151,7 +151,7 @@ export class DocumentManager {
};
const docView = getFirstDocView(targetDoc, originatingDoc);
let annotatedDoc = await Cast(targetDoc.annotationOn, Doc);
- if (annotatedDoc && !targetDoc?.isPushpin) {
+ if (annotatedDoc && annotatedDoc !== originatingDoc?.context && !targetDoc?.isPushpin) {
const first = getFirstDocView(annotatedDoc);
if (first) {
annotatedDoc = first.props.Document;
@@ -161,11 +161,13 @@ export class DocumentManager {
if (docView) { // we have a docView already and aren't forced to create a new one ... just focus on the document. TODO move into view if necessary otherwise just highlight?
if (originatingDoc?.isPushpin) {
docView.props.Document.hidden = !docView.props.Document.hidden;
+ finished?.();
}
else {
docView.select(false);
docView.props.Document.hidden && (docView.props.Document.hidden = undefined);
- docView.props.focus(docView.props.Document, willZoom, undefined, focusAndFinish);
+ // @ts-ignore
+ docView.props.focus(docView.props.Document, willZoom, undefined, focusAndFinish, annotatedDoc && annotatedDoc === originatingDoc?.context);
highlight();
}
} else {
@@ -193,11 +195,13 @@ export class DocumentManager {
if (retryDocView) { // we found the target in the context
retryDocView.props.focus(targetDoc, willZoom, undefined, focusAndFinish); // focus on the target in the context
highlight();
- }
- if (delay > 2500) {
+ } else if (delay > 1500) {
// we didn't find the target, so it must have moved out of the context. Go back to just creating it.
if (closeContextIfNotFound) targetDocContextView.props.removeDocument?.(targetDocContextView.props.Document);
- // targetDoc.layout && createViewFunc(Doc.BrushDoc(targetDoc), finished); // create a new view of the target
+ if (targetDoc.layout) {
+ Doc.SetInPlace(targetDoc, "annotationOn", undefined, false);
+ createViewFunc(Doc.BrushDoc(targetDoc), finished); // create a new view of the target
+ }
} else {
setTimeout(() => findView(delay + 250), 250);
}
@@ -214,7 +218,6 @@ export class DocumentManager {
public async FollowLink(link: Opt<Doc>, doc: Doc, createViewFunc: CreateViewFunc, zoom = false, currentContext?: Doc, finished?: () => void, traverseBacklink?: boolean) {
const linkDocs = link ? [link] : DocListCast(doc.links);
- SelectionManager.DeselectAll();
const firstDocs = linkDocs.filter(linkDoc => Doc.AreProtosEqual(linkDoc.anchor1 as Doc, doc) || Doc.AreProtosEqual((linkDoc.anchor1 as Doc).annotationOn as Doc, doc)); // link docs where 'doc' is anchor1
const secondDocs = linkDocs.filter(linkDoc => Doc.AreProtosEqual(linkDoc.anchor2 as Doc, doc) || Doc.AreProtosEqual((linkDoc.anchor2 as Doc).annotationOn as Doc, doc)); // link docs where 'doc' is anchor2
const fwdLinkWithoutTargetView = firstDocs.find(d => DocumentManager.Instance.getDocumentViews(d.anchor2 as Doc).length === 0);