diff options
author | bobzel <zzzman@gmail.com> | 2024-04-21 19:03:49 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-04-21 19:03:49 -0400 |
commit | 939e18624af4252551f38c43335ee8ef0acd144c (patch) | |
tree | d4e7a8dd4db05737ec1343ff8d80611537bde65b /src/client/util/LinkManager.ts | |
parent | 57d9c12d6b88d6814e468aca93b9bf809eabd9ce (diff) |
more lint cleanup
Diffstat (limited to 'src/client/util/LinkManager.ts')
-rw-r--r-- | src/client/util/LinkManager.ts | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts index 82cd791cc..c986bd674 100644 --- a/src/client/util/LinkManager.ts +++ b/src/client/util/LinkManager.ts @@ -25,6 +25,7 @@ import { ScriptingGlobals } from './ScriptingGlobals'; * - user defined kvps */ export class LinkManager { + // eslint-disable-next-line no-use-before-define @observable static _instance: LinkManager; @observable.shallow userLinkDBs: Doc[] = []; @observable public currentLink: Opt<Doc> = undefined; @@ -61,7 +62,7 @@ export class LinkManager { Promise.all(lAnchs.map(lAnch => PromiseValue(lAnch?.proto as Doc))).then((lAnchProtos: Opt<Doc>[]) => Promise.all(lAnchProtos.map(lAnchProto => PromiseValue(lAnchProto?.proto as Doc))).then( link && - action(lAnchProtoProtos => { + action(() => { Doc.AddDocToList(Doc.UserDoc(), 'links', link); lAnchs[0]?.[DocData][DirectLinks].add(link); lAnchs[1]?.[DocData][DirectLinks].add(link); @@ -78,7 +79,7 @@ export class LinkManager { Promise.all([lproto?.link_anchor_1 as Doc, lproto?.link_anchor_2 as Doc].map(PromiseValue)).then((lAnchs: Opt<Doc>[]) => Promise.all(lAnchs.map(lAnch => PromiseValue(lAnch?.proto as Doc))).then((lAnchProtos: Opt<Doc>[]) => Promise.all(lAnchProtos.map(lAnchProto => PromiseValue(lAnchProto?.proto as Doc))).then( - action(lAnchProtoProtos => { + action(() => { link && lAnchs[0] && lAnchs[0][DocData][DirectLinks].delete(link); link && lAnchs[1] && lAnchs[1][DocData][DirectLinks].delete(link); }) @@ -100,7 +101,8 @@ export class LinkManager { (change as any).added.forEach((link: any) => addLinkToDoc(toRealField(link))); (change as any).removed.forEach((link: any) => remLinkFromDoc(toRealField(link))); break; - case 'update': //let oldValue = change.oldValue; + case 'update': // let oldValue = change.oldValue; + default: } }, true @@ -120,6 +122,8 @@ export class LinkManager { added?.forEach((link: any) => addLinkToDoc(toRealField(link))); removed?.forEach((link: any) => remLinkFromDoc(toRealField(link))); }); + break; + default: } }, true @@ -133,7 +137,8 @@ export class LinkManager { case 'splice': (change as any).added.forEach(watchUserLinkDB); break; - case 'update': //let oldValue = change.oldValue; + case 'update': // let oldValue = change.oldValue; + default: } }, true @@ -143,7 +148,7 @@ export class LinkManager { } public createlink_relationshipLists = () => { - //create new lists for link relations and their associated colors if the lists don't already exist + // create new lists for link relations and their associated colors if the lists don't already exist !Doc.UserDoc().link_relationshipList && (Doc.UserDoc().link_relationshipList = new List<string>()); !Doc.UserDoc().link_ColorList && (Doc.UserDoc().link_ColorList = new List<string>()); !Doc.UserDoc().link_relationshipSizes && (Doc.UserDoc().link_relationshipSizes = new List<number>()); @@ -153,6 +158,7 @@ export class LinkManager { Doc.AddDocToList(Doc.UserDoc(), 'links', linkDoc); if (!checkExists || !DocListCast(Doc.LinkDBDoc().data).includes(linkDoc)) { Doc.AddDocToList(Doc.LinkDBDoc(), 'data', linkDoc); + // eslint-disable-next-line no-use-before-define setTimeout(UPDATE_SERVER_CACHE, 100); } } @@ -203,7 +209,7 @@ export class LinkManager { this.relatedLinker(anchor).forEach(link => { if (link.link_relationship && link.link_relationship !== '-ungrouped-') { const relation = StrCast(link.link_relationship); - const anchorRelation = relation.indexOf(':') !== -1 ? relation.split(':')[Doc.AreProtosEqual(Cast(link.link_anchor_1, Doc, null), anchor) ? 0 : 1] : relation; + const anchorRelation: string = relation.indexOf(':') !== -1 ? relation.split(':')[Doc.AreProtosEqual(Cast(link.link_anchor_1, Doc, null), anchor) ? 0 : 1] : relation; const group = anchorGroups.get(anchorRelation); anchorGroups.set(anchorRelation, group ? [...group, link] : [link]); } else { @@ -234,14 +240,7 @@ export class LinkManager { if (Doc.AreProtosEqual(DocCast(anchor?.annotationOn, anchor), DocCast(a1?.annotationOn, a1))) return '1'; if (Doc.AreProtosEqual(DocCast(anchor?.annotationOn, anchor), DocCast(a2?.annotationOn, a2))) return '2'; if (Doc.AreProtosEqual(anchor, linkDoc)) return '0'; - - // const a1 = DocCast(linkDoc.link_anchor_1); - // const a2 = DocCast(linkDoc.link_anchor_2); - // if (linkDoc.link_matchEmbeddings) { - // return [a2, a2.annotationOn].includes(anchor) ? '2' : '1'; - // } - // if (Doc.AreProtosEqual(a2, anchor) || Doc.AreProtosEqual(a2.annotationOn as Doc, anchor)) return '2'; - // return Doc.AreProtosEqual(a1, anchor) || Doc.AreProtosEqual(a1.annotationOn as Doc, anchor) ? '1' : '2'; + return undefined; } } @@ -282,6 +281,7 @@ export function UPDATE_SERVER_CACHE() { } ScriptingGlobals.add( + // eslint-disable-next-line prefer-arrow-callback function links(doc: any) { return new List(LinkManager.Links(doc)); }, |