aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/LinkManager.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/util/LinkManager.ts')
-rw-r--r--src/client/util/LinkManager.ts14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts
index 3e98ea379..8346949ba 100644
--- a/src/client/util/LinkManager.ts
+++ b/src/client/util/LinkManager.ts
@@ -1,4 +1,4 @@
-import { action, observable, observe, runInAction } from 'mobx';
+import { action, makeObservable, observable, observe, runInAction } from 'mobx';
import { computedFn } from 'mobx-utils';
import { Doc, DocListCast, DocListCastAsync, Field, Opt } from '../../fields/Doc';
import { DirectLinks } from '../../fields/DocSymbols';
@@ -22,7 +22,7 @@ import { ScriptingGlobals } from './ScriptingGlobals';
*/
export class LinkManager {
@observable static _instance: LinkManager;
- @observable static userLinkDBs: Doc[] = [];
+ @observable userLinkDBs: Doc[] = observable([]);
@observable public static currentLink: Opt<Doc>;
@observable public static currentLinkAnchor: Opt<Doc>;
public static get Instance() {
@@ -32,21 +32,21 @@ export class LinkManager {
public static Links(doc: Doc | undefined) {
return doc ? LinkManager.Instance.getAllRelatedLinks(doc) : [];
}
- public static addLinkDB = async (linkDb: any) => {
+ public 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?.link_anchor_1), PromiseValue(link?.link_anchor_2)]
)
);
- LinkManager.userLinkDBs.push(linkDb);
+ this.userLinkDBs.push(linkDb);
};
public static AutoKeywords = 'keywords:Usages';
static _links: Doc[] = [];
constructor() {
+ makeObservable(this);
LinkManager._instance = this;
this.createlink_relationshipLists();
- LinkManager.userLinkDBs = [];
// since this is an action, not a reaction, we get only one shot to add this link to the Anchor docs
// Thus make sure all promised values are resolved from link -> link.proto -> link.link_anchor_[1,2] -> link.link_anchor_[1,2].proto
// Then add the link to the anchor protos.
@@ -124,7 +124,7 @@ export class LinkManager {
}
};
observe(
- LinkManager.userLinkDBs,
+ this.userLinkDBs,
change => {
switch (change.type as any) {
case 'splice':
@@ -136,7 +136,7 @@ export class LinkManager {
true
);
runInAction(() => (FieldLoader.ServerLoadStatus.message = 'links'));
- LinkManager.addLinkDB(Doc.LinkDBDoc());
+ this.addLinkDB(Doc.LinkDBDoc());
}
public createlink_relationshipLists = () => {