aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/DocumentManager.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2020-09-10 12:09:52 -0400
committerbobzel <zzzman@gmail.com>2020-09-10 12:09:52 -0400
commite4017046bba5af099be31c2f18edc7bc45c12c4d (patch)
treecddd482c97a32bd568e5e4bf9986f144543b2de0 /src/client/util/DocumentManager.ts
parentd673482563d161171568682d745996598228baf2 (diff)
better fix for following links to pdfs
Diffstat (limited to 'src/client/util/DocumentManager.ts')
-rw-r--r--src/client/util/DocumentManager.ts25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index 5e43ab39a..f41c5e4cb 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -187,24 +187,21 @@ export class DocumentManager {
targetDocContext._currentTimecode = targetDoc.displayTimecode;
finished?.();
} else { // no timecode means we need to find the context view and focus on our target
- setTimeout(() => {
+ const findView = (delay: number) => {
const retryDocView = getFirstDocView(targetDoc); // test again for the target view snce we presumably created the context above by focusing on it
if (retryDocView) { // we found the target in the context
retryDocView.props.focus(targetDoc, willZoom, undefined, focusAndFinish); // focus on the target in the context
- } else { // we didn't find the target, so it must have moved out of the context. Go back to just creating it.
- setTimeout(() => {
- const retryDocView = getFirstDocView(targetDoc); // test again for the target view snce we presumably created the context above by focusing on it
- if (retryDocView) { // we found the target in the context
- retryDocView.props.focus(targetDoc, willZoom, undefined, focusAndFinish); // focus on the target in the context
- } else { // 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
- }
- highlight();
- }, 2000)
+ highlight();
}
- highlight();
- }, 250);
+ if (delay > 2500) {
+ // 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
+ } else {
+ setTimeout(() => findView(delay + 250), 250);
+ }
+ }
+ findView(0);
}
} else { // there's no context view so we need to create one first and try again
createViewFunc(targetDocContext); // so first we create the target, but don't pass finished because we still need to create the target