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

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

The store won’t autoload the reviewable category anymore as we removed that piece of code in #13412. This commit adds it as a computed property.

diff --git a/app/assets/javascripts/discourse/app/models/reviewable.js b/app/assets/javascripts/discourse/app/models/reviewable.js
index 47c095b..40475b1 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;

GitHub sha: 7e6a317597edb7d4b0eae1aeed9f8cb277458730

This commit appears in #13621 which was approved by eviltrout. It was merged by romanrizzi.