From e1826e302527cf428d82a7e8ee450385c901ead8 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 11 Sep 2014 17:40:38 -0400 Subject: [PATCH] Remove constants from initializers --- .../discourse/initializers/dynamic-route-builders.js.es6 | 5 +++-- .../javascripts/discourse/initializers/read-only.js.es6 | 5 +++-- .../initializers/register-discourse-location.js.es6 | 2 ++ .../initializers/subscribe-user-notifications.js.es6 | 9 ++++++--- .../discourse/initializers/verbose-localization.js.es6 | 6 ++++-- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/discourse/initializers/dynamic-route-builders.js.es6 b/app/assets/javascripts/discourse/initializers/dynamic-route-builders.js.es6 index f2726748086..f5f22866bac 100644 --- a/app/assets/javascripts/discourse/initializers/dynamic-route-builders.js.es6 +++ b/app/assets/javascripts/discourse/initializers/dynamic-route-builders.js.es6 @@ -11,7 +11,8 @@ export default { app.DiscoveryParentCategoryRoute = buildCategoryRoute('latest'); app.DiscoveryCategoryNoneRoute = buildCategoryRoute('latest', {no_subcategories: true}); - Discourse.Site.currentProp('filters').forEach(function(filter) { + var site = container.lookup('site:main'); + site.get('filters').forEach(function(filter) { app["Discovery" + filter.capitalize() + "Controller"] = DiscoverySortableController.extend(); app["Discovery" + filter.capitalize() + "Route"] = buildTopicRoute(filter); app["Discovery" + filter.capitalize() + "CategoryRoute"] = buildCategoryRoute(filter); @@ -29,7 +30,7 @@ export default { Discourse.DiscoveryTopCategoryRoute = buildCategoryRoute('top'); Discourse.DiscoveryTopCategoryNoneRoute = buildCategoryRoute('top', {no_subcategories: true}); - Discourse.Site.currentProp('periods').forEach(function(period) { + site.get('periods').forEach(function(period) { app["DiscoveryTop" + period.capitalize() + "Controller"] = DiscoverySortableController.extend(); app["DiscoveryTop" + period.capitalize() + "Route"] = buildTopicRoute('top/' + period); app["DiscoveryTop" + period.capitalize() + "CategoryRoute"] = buildCategoryRoute('top/' + period); diff --git a/app/assets/javascripts/discourse/initializers/read-only.js.es6 b/app/assets/javascripts/discourse/initializers/read-only.js.es6 index 83a4f61e62b..bb2313bd5bc 100644 --- a/app/assets/javascripts/discourse/initializers/read-only.js.es6 +++ b/app/assets/javascripts/discourse/initializers/read-only.js.es6 @@ -5,11 +5,12 @@ export default { name: "read-only", after: "message-bus", - initialize: function () { + initialize: function (container) { if (!Discourse.MessageBus) { return; } + var site = container.lookup('site:main'); Discourse.MessageBus.subscribe("/site/read-only", function (enabled) { - Discourse.Site.currentProp('isReadOnly', enabled); + site.currentProp('isReadOnly', enabled); }); } }; diff --git a/app/assets/javascripts/discourse/initializers/register-discourse-location.js.es6 b/app/assets/javascripts/discourse/initializers/register-discourse-location.js.es6 index 19d4206d3d7..e3ae8551ad0 100644 --- a/app/assets/javascripts/discourse/initializers/register-discourse-location.js.es6 +++ b/app/assets/javascripts/discourse/initializers/register-discourse-location.js.es6 @@ -1,5 +1,7 @@ export default { name: "register-discourse-location", + after: 'inject-objects', + initialize: function(container, application) { application.register('location:discourse-location', Ember.DiscourseLocation); } diff --git a/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 b/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 index 69deb2c28c4..f8aaac79199 100644 --- a/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 +++ b/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 @@ -4,11 +4,15 @@ export default { name: "subscribe-user-notifications", after: 'message-bus', - initialize: function() { + initialize: function(container) { var user = Discourse.User.current(); + + var site = container.lookup('site:main'), + siteSettings = container.lookup('site-settings:main'); + if (user) { var bus = Discourse.MessageBus; - bus.callbackInterval = Discourse.SiteSettings.polling_interval; + bus.callbackInterval = siteSettings.polling_interval; bus.enableLongPolling = true; bus.baseUrl = Discourse.getURL("/"); @@ -30,7 +34,6 @@ export default { }), user.notification_channel_position); bus.subscribe("/categories", function(data){ - var site = Discourse.Site.current(); _.each(data.categories,function(c){ site.updateCategory(c); }); diff --git a/app/assets/javascripts/discourse/initializers/verbose-localization.js.es6 b/app/assets/javascripts/discourse/initializers/verbose-localization.js.es6 index 80e5a2fb90b..71aca9f3f10 100644 --- a/app/assets/javascripts/discourse/initializers/verbose-localization.js.es6 +++ b/app/assets/javascripts/discourse/initializers/verbose-localization.js.es6 @@ -1,8 +1,10 @@ export default { name: 'verbose-localization', - initialize: function() { + after: 'inject-objects', - if(Discourse.SiteSettings.verbose_localization){ + initialize: function(container) { + var siteSettings = container.lookup('site-settings:main'); + if (siteSettings.verbose_localization) { I18n.enable_verbose_localization(); } }