FIX: Allow `category` to be set on `topic` model instances (#25416)
Some parts of our code (e.g. some types of reviewable) set `topic.category`. In the past this would override the computed property value, but with recent Ember it raises an error. This commit adds a setter which handles the situation cleanly
This commit is contained in:
parent
57ea56ee05
commit
1651d63204
|
@ -1,4 +1,4 @@
|
|||
import EmberObject from "@ember/object";
|
||||
import EmberObject, { computed } from "@ember/object";
|
||||
import { alias, and, equal, notEmpty, or } from "@ember/object/computed";
|
||||
import { Promise } from "rsvp";
|
||||
import { resolveShareUrl } from "discourse/helpers/share-url";
|
||||
|
@ -214,11 +214,15 @@ const Topic = RestModel.extend({
|
|||
return { type: "topic", id };
|
||||
},
|
||||
|
||||
@discourseComputed("category_id")
|
||||
category() {
|
||||
@computed("category_id")
|
||||
get category() {
|
||||
return Category.findById(this.category_id);
|
||||
},
|
||||
|
||||
set category(newCategory) {
|
||||
this.set("category_id", newCategory?.id);
|
||||
},
|
||||
|
||||
@discourseComputed("url")
|
||||
shareUrl(url) {
|
||||
const user = User.current();
|
||||
|
|
Loading…
Reference in New Issue