Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: encode in abstractlazilyencodablesection not returning updated string #78

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions modules/cmpapi/src/encoder/GppModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export class GppModel {
if (section) {
section.setFieldValue(fieldName, value);
this.dirty = true;
section.setIsDirty(true);
} else {
throw new InvalidFieldError(sectionName + "." + fieldName + " not found");
}
Expand Down Expand Up @@ -242,6 +243,7 @@ export class GppModel {
let sectionName = Sections.SECTION_ORDER[i];
if (sections.has(sectionName)) {
let section = sections.get(sectionName);
section.setIsDirty(true);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ankitonetrust - Please use the same method in all the places where isDirty is getting set directly. I suggest using a new method setIsDirty in GppModel, which will be responsible for setting the isDirty flag and syncing the same flag in AbstractLazilyEncodableSection as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @dev-spandey there is no dependency for isDirty in AbstractLazilyEncodableSection other than encode method and the same file takes care of setting isDirty false.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ankitonetrust I've been doing a little digging and I think to avoid the issue this change causes with the decoding is to move this line of code to line 114 of this same file. That way it only gets set for the specific task of setting field values, which was described in the original bug.

encodedSections.push(section.encode());
sectionIds.push(section.getId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,8 @@ export abstract class AbstractLazilyEncodableSection implements EncodableSection
this.dirty = false;
this.decoded = false;
}

public setIsDirty(status: boolean): void {
this.dirty = status;
}
}
2 changes: 2 additions & 0 deletions modules/cmpapi/src/encoder/section/EncodableSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ export interface EncodableSection {
encode(): string;

decode(encodedString: string): void;

setIsDirty(status: boolean): void;
}