DEV: Don't transition miniprofiler on first page load. (#14265)

DEV: Don’t transition miniprofiler on first page load. (#14265)

See Slow loading on private-message-topic-tracking-state.json - #5 by blattersturm - bug - Discourse Meta

diff --git a/app/assets/javascripts/discourse/app/initializers/page-tracking.js b/app/assets/javascripts/discourse/app/initializers/page-tracking.js
index 13858cb..df11851 100644
--- a/app/assets/javascripts/discourse/app/initializers/page-tracking.js
+++ b/app/assets/javascripts/discourse/app/initializers/page-tracking.js
@@ -15,8 +15,8 @@ export default {
     const router = container.lookup("router:main");
 
     router.on("routeWillChange", viewTrackingRequired);
-    router.on("routeDidChange", () => {
-      cleanDOM(container);
+    router.on("routeDidChange", (transition) => {
+      cleanDOM(container, { skipMiniProfilerPageTransition: !transition.from });
     });
 
     let appEvents = container.lookup("service:app-events");
diff --git a/app/assets/javascripts/discourse/app/lib/clean-dom.js b/app/assets/javascripts/discourse/app/lib/clean-dom.js
index 04156ec..00403b3 100644
--- a/app/assets/javascripts/discourse/app/lib/clean-dom.js
+++ b/app/assets/javascripts/discourse/app/lib/clean-dom.js
@@ -1,7 +1,7 @@
 import { scheduleOnce } from "@ember/runloop";
 
-function _clean() {
-  if (window.MiniProfiler) {
+function _clean(opts = {}) {
+  if (window.MiniProfiler && !opts.skipMiniProfilerPageTransition) {
     window.MiniProfiler.pageTransition();
   }
 
@@ -29,6 +29,6 @@ function _clean() {
   this.lookup("service:document-title").updateContextCount(0);
 }
 
-export function cleanDOM(container) {
-  scheduleOnce("afterRender", container, _clean);
+export function cleanDOM(container, opts) {
+  scheduleOnce("afterRender", container, _clean, opts);
 }

GitHub sha: aaa8a379b9aa4fccd7f2d4cf32524ad7aa1eb578

This commit appears in #14265 which was approved by SamSaffron. It was merged by tgxworld.