From 1ae625ec2e7ad6aae6b6f361ea9506baa5359fc6 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 2 Aug 2016 15:26:07 -0400 Subject: [PATCH] FIX: Archetype class wasn't being applied on refresh --- .../discourse/mixins/add-archetype-class.js.es6 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/mixins/add-archetype-class.js.es6 b/app/assets/javascripts/discourse/mixins/add-archetype-class.js.es6 index e1b710746..83889422f 100644 --- a/app/assets/javascripts/discourse/mixins/add-archetype-class.js.es6 +++ b/app/assets/javascripts/discourse/mixins/add-archetype-class.js.es6 @@ -1,21 +1,26 @@ +import { on, observes } from 'ember-addons/ember-computed-decorators'; + // Mix this in to a view that has a `archetype` property to automatically // add it to the body as the view is entered / left / model is changed. // This is used for keeping the `body` style in sync for the background image. export default { - _init: function() { this.get('archetype'); }.on('init'), - _cleanUp() { $('body').removeClass((_, css) => (css.match(/\barchetype-\S+/g) || []).join(' ')); }, - _archetypeChanged: function() { + @observes('archetype') + @on('init') + _archetypeChanged() { const archetype = this.get('archetype'); this._cleanUp(); if (archetype) { $('body').addClass('archetype-' + archetype); } - }.observes('archetype'), + }, - _willDestroyElement: function() { this._cleanUp(); }.on('willDestroyElement') + willDestroyElement() { + this._super(); + this._cleanUp(); + } };