FIX: when banner is removed update all clients

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.

diff --git a/app/assets/javascripts/discourse/initializers/banner.js.es6 b/app/assets/javascripts/discourse/initializers/banner.js.es6
index c8b422c..46e3899 100644
--- a/app/assets/javascripts/discourse/initializers/banner.js.es6
+++ b/app/assets/javascripts/discourse/initializers/banner.js.es6
@@ -5,7 +5,7 @@ export default {
   after: "message-bus",
 
   initialize(container) {
-    const banner = Ember.Object.create(PreloadStore.get("banner")),
+    const banner = Ember.Object.create(PreloadStore.get("banner") || {}),
       site = container.lookup("site:main");
 
     site.set("banner", banner);
@@ -16,7 +16,7 @@ export default {
     }
 
     messageBus.subscribe("/site/banner", function(ban) {
-      site.set("banner", Ember.Object.create(ban));
+      site.set("banner", Ember.Object.create(ban || {}));
     });
   }
 };

GitHub sha: 88f8c9f4

1 Like