diff --git a/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 b/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 index ab04fcb..f7ee458 100644 --- a/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 +++ b/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 @@ -11,25 +11,7 @@ export default { name: 'extend-for-solved-button', initialize: function() { - Discourse.Category.reopen({ - - @computed("custom_fields") - enable_accepted_answers: { - get() { - const fields = this.get("custom_fields"); - return fields && fields.enable_accepted_answers === "true"; - }, - set(value) { - value = value ? "true" : "false"; - this.set("custom_fields.enable_accepted_answers", value); - return value; - } - } - - }); - Topic.reopen({ - // keeping this here cause there is complex localization acceptedAnswerHtml: function(){ const username = this.get('accepted_answer.username'); diff --git a/assets/javascripts/discourse/pre-initializers/extend-category-for-solved.js.es6 b/assets/javascripts/discourse/pre-initializers/extend-category-for-solved.js.es6 new file mode 100644 index 0000000..700a138 --- /dev/null +++ b/assets/javascripts/discourse/pre-initializers/extend-category-for-solved.js.es6 @@ -0,0 +1,25 @@ +import property from 'ember-addons/ember-computed-decorators'; +import Category from 'discourse/models/category'; + +export default { + name: 'extend-category-for-solved', + before: 'inject-discourse-objects', + initialize() { + + Category.reopen({ + + @property('custom_fields.enable_accepted_answers') + enable_accepted_answers: { + get(enableField) { + return enableField === "true"; + }, + set(value) { + value = value ? "true" : "false"; + this.set("custom_fields.enable_accepted_answers", value); + return value; + } + } + + }); + } +};