diff options
author | bob <bcz@cs.brown.edu> | 2019-10-10 16:42:12 -0400 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2019-10-10 16:42:12 -0400 |
commit | 21aab2fbf28e9cf6d08366b57d368d120d6813bb (patch) | |
tree | 1eeda85f15283787b5b982975c2c5fed9692fd3e /src/new_fields/Doc.ts | |
parent | 77d66d159d75442ff5635c4bf4843b6155883cc2 (diff) |
got rid of all CollectionView wrappers around XxxBox's added DocAnnotatableComponent
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r-- | src/new_fields/Doc.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 418863bcc..eb752f8c6 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -332,8 +332,10 @@ export namespace Doc { return Array.from(results); } - export function IndexOf(toFind: Doc, list: Doc[]) { - return list.findIndex(doc => doc === toFind || Doc.AreProtosEqual(doc, toFind)); + export function IndexOf(toFind: Doc, list: Doc[], allowProtos: boolean = true) { + let index = list.reduce((p, v, i) => (v instanceof Doc && v === toFind) ? i : p, -1); + index = allowProtos && index !== -1 ? index : list.reduce((p, v, i) => (v instanceof Doc && Doc.AreProtosEqual(v, toFind)) ? i : p, -1); + return index; // list.findIndex(doc => doc === toFind || Doc.AreProtosEqual(doc, toFind)); } export function RemoveDocFromList(listDoc: Doc, key: string, doc: Doc) { if (listDoc[key] === undefined) { |