From 88d95fff8f0e08f5ec00b9fe422d41b716295719 Mon Sep 17 00:00:00 2001 From: Tyler Peryea Date: Wed, 14 Aug 2024 01:52:07 -0400 Subject: [PATCH] Update substance-form.service.ts Since js is 0-indexed, we need to start from length-1 and go down. There was old code that was starting from length instead, which is out of range. This still used to work because there were checks inside for whether the value at that invalid index was "truthy". Just switching it to start at the right index is easier though --- .../core/substance-form/substance-form.service.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/core/substance-form/substance-form.service.ts b/src/app/core/substance-form/substance-form.service.ts index cff68e787..e924635f2 100644 --- a/src/app/core/substance-form/substance-form.service.ts +++ b/src/app/core/substance-form/substance-form.service.ts @@ -1421,9 +1421,9 @@ export class SubstanceFormService implements OnDestroy { if (this.privateSubstance.protein && this.privateSubstance.protein.disulfideLinks && this.privateSubstance.protein.disulfideLinks.length > 0) { - for (let i = this.privateSubstance.protein.disulfideLinks.length; i >= 0; i--) { + for (let i = this.privateSubstance.protein.disulfideLinks.length -1; i >= 0; i--) { if (this.privateSubstance.protein.disulfideLinks[i].sitesShorthand) { - // delete this.privateSubstance.protein.disulfideLinks[i].sitesShorthand; + delete this.privateSubstance.protein.disulfideLinks[i].sitesShorthand; } if (this.privateSubstance.protein.disulfideLinks[i] && this.privateSubstance.protein.disulfideLinks[i].sites && this.privateSubstance.protein.disulfideLinks[i].sites[0] && this.privateSubstance.protein.disulfideLinks[i].sites[1] && @@ -1435,16 +1435,16 @@ export class SubstanceFormService implements OnDestroy { if (this.privateSubstance.nucleicAcid) { if (this.privateSubstance.nucleicAcid.linkages && this.privateSubstance.nucleicAcid.linkages.length > 0) { - for (let i = this.privateSubstance.nucleicAcid.linkages.length; i >= 0; i--) { + for (let i = this.privateSubstance.nucleicAcid.linkages.length-1; i >= 0; i--) { if (this.privateSubstance.nucleicAcid.linkages[i].sitesShorthand) { - // delete this.privateSubstance.nucleicAcid.linkages[i].sitesShorthand; + delete this.privateSubstance.nucleicAcid.linkages[i].sitesShorthand; } } } if (this.privateSubstance.nucleicAcid.sugars && this.privateSubstance.nucleicAcid.sugars.length > 0) { - for (let i = this.privateSubstance.nucleicAcid.sugars.length; i >= 0; i--) { + for (let i = this.privateSubstance.nucleicAcid.sugars.length-1; i >= 0; i--) { if (this.privateSubstance.nucleicAcid.sugars[i].sitesShorthand) { - // delete this.privateSubstance.nucleicAcid.sugars[i].sitesShorthand; + delete this.privateSubstance.nucleicAcid.sugars[i].sitesShorthand; } } }