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.
This commit is contained in:
Roman Rizzi 2021-07-02 18:25:51 -03:00 committed by GitHub
parent 02999f5eb2
commit 7e6a317597
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 1 deletions

View File

@ -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;