mirror of
https://github.com/discourse/discourse.git
synced 2025-02-06 03:18:23 +00:00
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 { alias, and, equal, notEmpty, or } from "@ember/object/computed";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
import { resolveShareUrl } from "discourse/helpers/share-url";
|
import { resolveShareUrl } from "discourse/helpers/share-url";
|
||||||
@ -214,11 +214,15 @@ const Topic = RestModel.extend({
|
|||||||
return { type: "topic", id };
|
return { type: "topic", id };
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("category_id")
|
@computed("category_id")
|
||||||
category() {
|
get category() {
|
||||||
return Category.findById(this.category_id);
|
return Category.findById(this.category_id);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
set category(newCategory) {
|
||||||
|
this.set("category_id", newCategory?.id);
|
||||||
|
},
|
||||||
|
|
||||||
@discourseComputed("url")
|
@discourseComputed("url")
|
||||||
shareUrl(url) {
|
shareUrl(url) {
|
||||||
const user = User.current();
|
const user = User.current();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user