REFACTOR: Remove Discourse constants from cleanDOM

This commit is contained in:
Robin Ward
2020-08-06 15:34:20 -04:00
parent db443d2289
commit f03f58e52c
2 changed files with 9 additions and 8 deletions

View File

@@ -15,7 +15,9 @@ export default {
const router = container.lookup("router:main"); const router = container.lookup("router:main");
router.on("routeWillChange", viewTrackingRequired); router.on("routeWillChange", viewTrackingRequired);
router.on("routeDidChange", cleanDOM); router.on("routeDidChange", () => {
cleanDOM(container);
});
let appEvents = container.lookup("service:app-events"); let appEvents = container.lookup("service:app-events");
let documentTitle = container.lookup("service:document-title"); let documentTitle = container.lookup("service:document-title");

View File

@@ -1,4 +1,5 @@
import { scheduleOnce } from "@ember/runloop"; import { scheduleOnce } from "@ember/runloop";
function _clean() { function _clean() {
if (window.MiniProfiler) { if (window.MiniProfiler) {
window.MiniProfiler.pageTransition(); window.MiniProfiler.pageTransition();
@@ -23,18 +24,16 @@ function _clean() {
.not(".no-blur") .not(".no-blur")
.blur(); .blur();
Discourse.set("contextCount", 0); this.lookup("route:application").send("closeModal");
Discourse.__container__.lookup("route:application").send("closeModal");
const hideDropDownFunction = $("html").data("hide-dropdown"); const hideDropDownFunction = $("html").data("hide-dropdown");
if (hideDropDownFunction) { if (hideDropDownFunction) {
hideDropDownFunction(); hideDropDownFunction();
} }
// TODO: Avoid container lookup here this.lookup("service:app-events").trigger("dom:clean");
const appEvents = Discourse.__container__.lookup("service:app-events"); this.lookup("service:document-title").updateContextCount(0);
appEvents.trigger("dom:clean");
} }
export function cleanDOM() { export function cleanDOM(container) {
scheduleOnce("afterRender", _clean); scheduleOnce("afterRender", container, _clean);
} }