Fix patch range select on diff
Previously, the patch range selector was updated to not use two way
bindings (https://gerrit-review.googlesource.com/c/gerrit/+/130453) but
the diff view's usage was not updated as well. This change updates the
diff view to use the patch range select in the same way as the file
list.
Bug: Issue 7420
Change-Id: I1baaf643e08d1a4661962021be890bafd6d5b4ef
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
index 8455e1c..b97d974 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
@@ -61,24 +61,8 @@
value() { return {}; },
observer: '_changeViewStateChanged',
},
-
+ /** @type {?} */
_patchRange: Object,
- // These are kept as separate properties from the patchRange so that the
- // observer can be aware of the previous value. In order to view sub
- // property changes for _patchRange, a complex observer must be used, and
- // that only displays the new value.
- //
- // If a previous value did not exist, the change is not reloaded with the
- // new patches. This is just the initial setting from the change view vs.
- // an update coming from the two way data binding.
- _patchNum: {
- type: String,
- observer: '_patchOrBaseChanged',
- },
- _basePatchNum: {
- type: String,
- observer: '_patchOrBaseChanged',
- },
/**
* @type {{
* subject: string,
@@ -166,7 +150,6 @@
'_getProjectConfig(_change.project)',
'_getFiles(_changeNum, _patchRange.*)',
'_setReviewedObserver(_loggedIn, params.*)',
- '_patchRangeChanged(_patchRange.*)',
],
keyBindings: {
@@ -584,17 +567,6 @@
this.$.cursor.initialLineNumber = params.lineNum;
},
- _patchRangeChanged() {
- this._basePatchNum = this._patchRange.basePatchNum;
- this._patchNum = this._patchRange.patchNum;
- },
-
- _patchOrBaseChanged(patchNew, patchOld) {
- if (!patchOld) { return; }
-
- this._handlePatchChange(this._basePatchNum, this._patchNum);
- },
-
_pathChanged(path) {
if (path) {
this.fire('title-change',
@@ -701,7 +673,10 @@
this.$.dropdown.open();
},
- _handlePatchChange(basePatchNum, patchNum) {
+ _handlePatchChange(e) {
+ const {basePatchNum, patchNum} = e.detail;
+ if (this.patchNumEquals(basePatchNum, this._patchRange.basePatchNum) &&
+ this.patchNumEquals(patchNum, this._patchRange.patchNum)) { return; }
Gerrit.Nav.navigateToDiff(
this._change, this._path, patchNum, basePatchNum);
},