aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/LinkManager.ts
diff options
context:
space:
mode:
authorbrynnchernosky <56202540+brynnchernosky@users.noreply.github.com>2023-01-25 19:01:34 -0500
committerbrynnchernosky <56202540+brynnchernosky@users.noreply.github.com>2023-01-25 19:01:34 -0500
commit4fe5eebb3a02ac7cb86a54aa4350ae40cbfdd343 (patch)
tree6ff64205c634fed55411305b689e92f353c7b14c /src/client/util/LinkManager.ts
parent8d015ff599c145578166dda3013c6aaec1d34450 (diff)
parent1763ff090ea734ca275c3c28edc6c303c935b801 (diff)
Merge branch 'master' of github.com:brown-dash/Dash-Web into master
Diffstat (limited to 'src/client/util/LinkManager.ts')
-rw-r--r--src/client/util/LinkManager.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts
index 67c4669dd..7da16ca78 100644
--- a/src/client/util/LinkManager.ts
+++ b/src/client/util/LinkManager.ts
@@ -3,7 +3,7 @@ import { computedFn } from 'mobx-utils';
import { DirectLinksSym, Doc, DocListCast, DocListCastAsync, Field, Opt } from '../../fields/Doc';
import { List } from '../../fields/List';
import { ProxyField } from '../../fields/Proxy';
-import { Cast, DocCast, StrCast } from '../../fields/Types';
+import { Cast, DocCast, PromiseValue, StrCast } from '../../fields/Types';
/*
* link doc:
* - anchor1: doc
@@ -24,7 +24,15 @@ export class LinkManager {
public static get Instance() {
return LinkManager._instance;
}
- public static addLinkDB = (linkDb: any) => LinkManager.userLinkDBs.push(linkDb);
+ public static addLinkDB = async (linkDb: any) => {
+ await Promise.all(
+ ((await DocListCastAsync(linkDb.data)) ?? []).map(link =>
+ // makes sure link anchors are loaded to avoid incremental updates to computedFns in LinkManager
+ [PromiseValue(link?.anchor1), PromiseValue(link?.anchor2)]
+ )
+ );
+ LinkManager.userLinkDBs.push(linkDb);
+ };
public static AutoKeywords = 'keywords:Usages';
static links: Doc[] = [];
constructor() {