This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/initializers/banner.js.es6
Sam Saffron 88f8c9f43e FIX: when banner is removed update all clients
Previously removing a banner raised a null "banner" in the message bus
channel.

Then Ember.Object.create would fail cause it always expects an object in
constructor.
2019-04-10 15:59:29 +10:00

23 lines
516 B
JavaScript

import PreloadStore from "preload-store";
export default {
name: "banner",
after: "message-bus",
initialize(container) {
const banner = Ember.Object.create(PreloadStore.get("banner") || {}),
site = container.lookup("site:main");
site.set("banner", banner);
const messageBus = container.lookup("message-bus:main");
if (!messageBus) {
return;
}
messageBus.subscribe("/site/banner", function(ban) {
site.set("banner", Ember.Object.create(ban || {}));
});
}
};