Remove `viewStateChanged()` method from gr-change-view The deed is done. This was the ultimate target of a large chain of refactorings: Do not let the change view handle view state updates in a complicated tree of paths, but instead let the change model react in specific independent subscriptions. And let the view just subscribe to model updates. The major missing change that was still needed, was the handling of firing and handling reload events. Unfortunately clearing the patchset and forcing a reload was also been handled by a `reload` event, but clearing the patchset is a view state change, so this should be a direct command to the model. So we have looked at all `fireReload()` and `fireReload(true)` instances and checked which one is more appropriate: Keeping firing the "soft" reload or requesting a new view state. One issue was that the `forceReload` URL parameter was only handled by the change view. We are handling this now in the change view model. We have unified the entire reload handling in the change view model: The `reload` event, the `reload()` method of the view model and the `forceReload` URL parameter all end up in the same place: We are always resetting the view state to `undefined` in order to trigger a reload. That is very robust and reliable and allows us to also get rid of some dedicated `reload$` observables that we don't need anymore. Stop logging `change-view-re-rendered`. We don't need that anymore. Release-Notes: skip Change-Id: Ie6319089dee7586c04c01b2ae91c18bc75f0d85d
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts index 304f9ea..aa6bb7a4 100644 --- a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts +++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
@@ -1326,10 +1326,10 @@ }; const queryMap = new URLSearchParams(ctx.querystring); - if (queryMap.has('forceReload')) state.forceReload = true; if (queryMap.has('openReplyDialog')) state.openReplyDialog = true; const tab = queryMap.get('tab'); + if (queryMap.has('forceReload')) state.forceReload = true; if (tab) state.tab = tab; const checksPatchset = Number(queryMap.get('checksPatchset')); if (Number.isInteger(checksPatchset) && checksPatchset > 0) { @@ -1422,6 +1422,8 @@ view: GerritView.CHANGE, childView: ChangeChildView.OVERVIEW, }; + const queryMap = new URLSearchParams(ctx.querystring); + if (queryMap.has('forceReload')) state.forceReload = true; assertIsDefined(state.repo); this.reporting.setRepoName(state.repo); this.reporting.setChangeId(changeNum); @@ -1443,6 +1445,8 @@ childView: ChangeChildView.DIFF, diffView: {path: ctx.params[8]}, }; + const queryMap = new URLSearchParams(ctx.querystring); + if (queryMap.has('forceReload')) state.forceReload = true; const address = this.parseLineAddress(ctx.hash); if (address) { state.diffView!.leftSide = address.leftSide; @@ -1493,6 +1497,8 @@ childView: ChangeChildView.EDIT, editView: {path: ctx.params[3], lineNum: Number(ctx.hash)}, }; + const queryMap = new URLSearchParams(ctx.querystring); + if (queryMap.has('forceReload')) state.forceReload = true; this.normalizePatchRangeParams(state); // Note that router model view must be updated before view models. this.setState(state); @@ -1516,14 +1522,7 @@ }; const tab = queryMap.get('tab'); if (tab) state.tab = tab; - if (queryMap.has('forceReload')) { - state.forceReload = true; - history.replaceState( - null, - '', - location.href.replace(/[?&]forceReload=true/, '') - ); - } + if (queryMap.has('forceReload')) state.forceReload = true; this.normalizePatchRangeParams(state); // Note that router model view must be updated before view models. this.setState(state);