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.ts11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts
index c7c45ec61..4f3cfcd03 100644
--- a/src/client/util/LinkManager.ts
+++ b/src/client/util/LinkManager.ts
@@ -2,6 +2,7 @@ import { Doc, DocListCast, Opt } from "../../fields/Doc";
import { List } from "../../fields/List";
import { listSpec } from "../../fields/Schema";
import { Cast, StrCast } from "../../fields/Types";
+import { CurrentUserUtils } from "./CurrentUserUtils";
/*
* link doc:
@@ -61,10 +62,12 @@ export class LinkManager {
// finds all links that contain the given anchor
public getAllDirectLinks(anchor: Doc): Doc[] {
- const related = LinkManager.Instance.getAllLinks().filter(link => {
- const protomatch1 = Doc.AreProtosEqual(anchor, Cast(link.anchor1, Doc, null));
- const protomatch2 = Doc.AreProtosEqual(anchor, Cast(link.anchor2, Doc, null));
- return protomatch1 || protomatch2 || Doc.AreProtosEqual(link, anchor);
+ const related = LinkManager.Instance.getAllLinks().filter(link => link).filter(link => {
+ const a1 = Cast(link.anchor1, Doc, null)
+ const a2 = Cast(link.anchor2, Doc, null);
+ const protomatch1 = Doc.AreProtosEqual(anchor, a1);
+ const protomatch2 = Doc.AreProtosEqual(anchor, a2);
+ return ((a1?.title !== undefined && a2?.title !== undefined) || link.author === Doc.CurrentUserEmail) && (protomatch1 || protomatch2 || Doc.AreProtosEqual(link, anchor));
});
return related;
}