Refactoring the 'reload' event
The goal is to be able to listen on 'reload' events in multiple
services independently. So 'reload' is not under the total control
of a specific page (e.g. the change view).
We introduce a fireReload() utility and try using that all over the
app. The change view also tries to just fireReload() instead of
calling _reload() directly. Renaming _reload() to loadData() to
ensure that this is not used for the purpose of reloading anymore.
We remove the generic fallback handler from app-element that would
issue a window.location.reload(), if the page does not handle the
event. We don't want to stop propagating the 'reload' event so
that the checks service will also get it when listening on
document events.
The refactoring was motivated by bogus check reloads:
In change 295947 we wanted to fix that all the checks reload when the
change view *refreshes* (e.g. by pressing Shift-R). But that also
triggered checks reloading when the change view switches to another
change, which means reloading twice for no good reason. And even
worse, the checks service gets the change number from another source,
so it does the unnecessary reload even with the wrong change number.
Change-Id: Idaba673e066e3cb1f5b92651f5ac6a605fec8c98
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts
index bf61aa5..cf8d854 100644
--- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts
@@ -107,6 +107,7 @@
fireAlert,
fireEvent,
fireIronAnnounce,
+ fireReload,
fireServerError,
} from '../../../utils/event-util';
import {ErrorCallback} from '../../../api/rest';
@@ -1369,13 +1370,7 @@
}
_reload() {
- this.dispatchEvent(
- new CustomEvent('reload', {
- detail: {clearPatchset: true},
- bubbles: false,
- composed: true,
- })
- );
+ fireReload(this, true);
this.cancel();
}