Skip to content

A platform for community discussion. Free, open, simple.

FIX: Load the category when the category_id attr is present. (#13621)

Roman Rizzi7e6a317597ed
diff --git a/app/assets/javascripts/discourse/app/models/reviewable.js b/app/assets/javascripts/discourse/app/models/reviewable.js
index 47c095bb46a..40475b19ee1 100644
--- a/app/assets/javascripts/discourse/app/models/reviewable.js
+++ b/app/assets/javascripts/discourse/app/models/reviewable.js
@@ -11,7 +11,7 @@ export const REJECTED = 2;
export const IGNORED = 3;
export const DELETED = 4;
-export default RestModel.extend({
+const Reviewable = RestModel.extend({
@discourseComputed("type", "topic")
humanType(type, topic) {
// Display "Queued Topic" if the post will create a topic
@@ -24,6 +24,11 @@ export default RestModel.extend({
});
},
+ @discourseComputed("category_id")
+ category(categoryId) {
+ return Category.findById(categoryId);
+ },
+
update(updates) {
// If no changes, do nothing
if (Object.keys(updates).length === 0) {
@@ -50,3 +55,13 @@ export default RestModel.extend({
});
},
});
+
+Reviewable.reopenClass({
+ munge(json) {
+ // ensure we are not overriding category computed property
+ delete json.category;
+ return json;
+ },
+});
+
+export default Reviewable;