aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/DocumentManager.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-10-31 14:21:51 -0400
committerbobzel <zzzman@gmail.com>2023-10-31 14:21:51 -0400
commitcf95923feebb274249283c7bb82de5849060a9a8 (patch)
treeb4aafffb6ae32d4386f6a4ddfc6b6b01c6e309ff /src/client/util/DocumentManager.ts
parenta091c6142db5c1da94807abf14e78ed69e62f794 (diff)
fixed keyframe animation of ink and links. fixed getDocumentview with preferred collection
Diffstat (limited to 'src/client/util/DocumentManager.ts')
-rw-r--r--src/client/util/DocumentManager.ts18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index b9f6059f4..f7eca2379 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -146,22 +146,14 @@ export class DocumentManager {
return this.getDocumentViewsById(doc[Id]);
}
- public getDocumentView(toFind: Doc | undefined, preferredCollection?: DocumentView): DocumentView | undefined {
- const doc =
- // bcz: this was temporary code used to match documents by data url instead of by id. intended only for repairing the DB
- // Array.from(DocumentManager.Instance.DocumentViews).find(
- // dv =>
- // ((dv.rootDoc.data as any)?.url?.href && (dv.rootDoc.data as any)?.url?.href === (toFind.data as any)?.url?.href) ||
- // ((DocCast(dv.rootDoc.annotationOn)?.data as any)?.url?.href && (DocCast(dv.rootDoc.annotationOn)?.data as any)?.url?.href === (DocCast(toFind.annotationOn)?.data as any)?.url?.href)
- // )?.rootDoc ??
- toFind;
+ public getDocumentView(target: Doc | undefined, preferredCollection?: DocumentView): DocumentView | undefined {
const docViewArray = DocumentManager.Instance.DocumentViews;
- const passes = !doc ? [] : preferredCollection ? [preferredCollection, undefined] : [undefined];
+ const passes = !target ? [] : preferredCollection ? [preferredCollection, undefined] : [undefined];
return passes.reduce(
- (pass, toReturn) =>
+ (toReturn, pass) =>
toReturn ??
- docViewArray.filter(view => view.rootDoc === doc).find(view => !pass || view.props.docViewPath().lastElement() === preferredCollection) ??
- docViewArray.filter(view => Doc.AreProtosEqual(view.rootDoc, doc)).find(view => !pass || view.props.docViewPath().lastElement() === preferredCollection),
+ docViewArray.filter(view => view.rootDoc === target).find(view => !pass || view.props.docViewPath().lastElement() === preferredCollection) ??
+ docViewArray.filter(view => Doc.AreProtosEqual(view.rootDoc, target)).find(view => !pass || view.props.docViewPath().lastElement() === preferredCollection),
undefined as Opt<DocumentView>
);
}