diff options
author | bobzel <zzzman@gmail.com> | 2020-10-08 15:02:07 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2020-10-08 15:02:07 -0400 |
commit | 4382865d1ff1c39020a0cfc4be084a19a2f13c41 (patch) | |
tree | 0f85c0513948b24ef058fb7206b97a1be4cd8b7c /src | |
parent | f510f29e85a968e6b4975ae3f0129fe7713f8f2e (diff) |
made computedFn's out of getRlatedLinks calls
Diffstat (limited to 'src')
-rw-r--r-- | src/client/util/LinkManager.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts index a2bb16dfc..56b6cb8a9 100644 --- a/src/client/util/LinkManager.ts +++ b/src/client/util/LinkManager.ts @@ -3,6 +3,7 @@ import { List } from "../../fields/List"; import { listSpec } from "../../fields/Schema"; import { Cast, StrCast } from "../../fields/Types"; import { SharingManager } from "./SharingManager"; +import { computedFn } from "mobx-utils"; /* * link doc: @@ -59,13 +60,18 @@ export class LinkManager { }); return related; } - // finds all links that contain the given anchor - public getAllRelatedLinks(anchor: Doc): Doc[] { + + relatedLinker = computedFn(function realtedLinker(this: any, anchor: Doc) { const related = LinkManager.Instance.getAllDirectLinks(anchor); DocListCast(anchor[Doc.LayoutFieldKey(anchor) + "-annotations"]).map(anno => { related.push(...LinkManager.Instance.getAllRelatedLinks(anno)); }); return related; + }.bind(this)); + + // finds all links that contain the given anchor + public getAllRelatedLinks(anchor: Doc): Doc[] { + return this.relatedLinker(anchor); } public deleteAllLinksOnAnchor(anchor: Doc) { |