commit f196cad7981307d6b805e377f66fdd3dde62066d Author: Dhruv Srivastava Date: Wed Oct 14 15:12:15 2020 +0200 Fix patchset comparison when adding coverages Change-Id: I17f1a0c624547eb80db6db4f78c7b7ea3c9fe3d7 diff --git a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.ts b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.ts index c1b17fe..e7c9a4a 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.ts +++ b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.ts @@ -407,12 +407,12 @@ export class GrDiffHost extends GestureEventListeners( const changeNum = this.changeNum; const path = this.path; // Coverage providers do not provide data for EDIT and PARENT patch sets. - const basePatchNum = isNumber(this.patchRange.basePatchNum) - ? this.patchRange.basePatchNum - : undefined; - const patchNum = isNumber(this.patchRange.patchNum) - ? this.patchRange.patchNum - : undefined; + + const toNumberOnly = (patchNum: PatchSetNum) => + isNumber(patchNum) ? patchNum : undefined; + + const basePatchNum = toNumberOnly(this.patchRange.basePatchNum); + const patchNum = toNumberOnly(this.patchRange.patchNum); this.$.jsAPI .getCoverageAnnotationApi() .then(coverageAnnotationApi => { @@ -426,8 +426,8 @@ export class GrDiffHost extends GestureEventListeners( !coverageRanges || changeNum !== this.changeNum || path !== this.path || - basePatchNum !== this.patchRange.basePatchNum || - patchNum !== this.patchRange.patchNum + basePatchNum !== toNumberOnly(this.patchRange.basePatchNum) || + patchNum !== toNumberOnly(this.patchRange.patchNum) ) { return; }