REFACTOR: live-development.js (#16548)

- drop jquery
- replaces setTimeout by later
- removes dead code which is not even working today
This commit is contained in:
Joffrey JAFFEUX 2022-04-25 19:34:16 +02:00 committed by GitHub
parent f7540aa52f
commit 596469a712
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 24 deletions

View File

@ -1,9 +1,11 @@
import DiscourseURL from "discourse/lib/url";
import { isDevelopment } from "discourse-common/config/environment";
import { later } from "@ember/runloop";
// Use the message bus for live reloading of components for faster development.
export default {
name: "live-development",
initialize(container) {
const messageBus = container.lookup("message-bus:main");
const session = container.lookup("session:main");
@ -30,17 +32,6 @@ export default {
});
}
// Custom header changes
$("header.custom").each(function () {
const header = $(this);
return messageBus.subscribe(
"/header-change/" + $(this).data("id"),
function (data) {
return header.html(data);
}
);
});
// Useful to export this for debugging purposes
if (isDevelopment()) {
window.DiscourseURL = DiscourseURL;
@ -79,14 +70,9 @@ export default {
},
refreshCSS(node, newHref) {
let reloaded = node.cloneNode(true);
const reloaded = node.cloneNode(true);
reloaded.href = newHref;
node.insertAdjacentElement("afterend", reloaded);
setTimeout(() => {
if (node && node.parentNode) {
node.parentNode.removeChild(node);
}
}, 500);
later(() => node?.parentNode?.removeChild(node), 500);
},
};

View File

@ -580,12 +580,6 @@ class ThemeField < ActiveRecord::Base
dependent_fields.each(&:invalidate_baked!)
end
after_commit do
# TODO message for mobile vs desktop
MessageBus.publish "/header-change/#{theme.id}", self.value if theme && self.name == "header"
MessageBus.publish "/footer-change/#{theme.id}", self.value if theme && self.name == "footer"
end
after_destroy do
if svg_sprite_field?
DB.after_commit { SvgSprite.expire_cache }