Skip to content

Commit

Permalink
Update substance-form.service.ts
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tylerperyea authored Aug 14, 2024
1 parent e74c059 commit 88d95ff
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/app/core/substance-form/substance-form.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] &&
Expand All @@ -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;
}
}
}
Expand Down

0 comments on commit 88d95ff

Please sign in to comment.