mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 20:03:15 +08:00
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:
parent
f7540aa52f
commit
596469a712
|
@ -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);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -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 }
|
||||
|
|
Loading…
Reference in New Issue
Block a user