diff options
author | Fawn <fangrui_tong@brown.edu> | 2019-06-21 17:41:20 -0400 |
---|---|---|
committer | Fawn <fangrui_tong@brown.edu> | 2019-06-21 17:41:20 -0400 |
commit | 32ef8d83d5829e2faadbebaf6f9b694df5d7ea02 (patch) | |
tree | 43105f51af6e03af2ddfed7fe4f2983793829539 /src/client/util/LinkManager.ts | |
parent | 7962aff8431b692af5229cd8e6c390bbe1110336 (diff) |
link menu styling
Diffstat (limited to 'src/client/util/LinkManager.ts')
-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 544f2edda..fef996bb9 100644 --- a/src/client/util/LinkManager.ts +++ b/src/client/util/LinkManager.ts @@ -3,6 +3,7 @@ import { StrCast, Cast } from "../../new_fields/Types"; import { Doc, DocListCast } from "../../new_fields/Doc"; import { listSpec } from "../../new_fields/Schema"; import { List } from "../../new_fields/List"; +import { Id } from "../../new_fields/FieldSymbols"; /* @@ -36,8 +37,13 @@ export class LinkManager { // finds all links that contain the given anchor public findAllRelatedLinks(anchor: Doc): Array<Doc> { - return LinkManager.Instance.allLinks.filter( - link => Doc.AreProtosEqual(anchor, Cast(link.anchor1, Doc, new Doc)) || Doc.AreProtosEqual(anchor, Cast(link.anchor2, Doc, new Doc))); + return LinkManager.Instance.allLinks.filter(link => { + let protomatch1 = Doc.AreProtosEqual(anchor, Cast(link.anchor1, Doc, new Doc)); + let protomatch2 = Doc.AreProtosEqual(anchor, Cast(link.anchor2, Doc, new Doc)); + let idmatch1 = StrCast(anchor[Id]) === StrCast(Cast(link.anchor1, Doc, new Doc)[Id]); + let idmatch2 = StrCast(anchor[Id]) === StrCast(Cast(link.anchor2, Doc, new Doc)[Id]); + return protomatch1 || protomatch2 || idmatch1 || idmatch2; + }); } // returns map of group type to anchor's links in that group type |