FIX: convert topic & post models to ember object.
This commit is contained in:
parent
09da5dd7bb
commit
cd3b58358e
|
@ -6,11 +6,20 @@ export default Ember.Component.extend({
|
|||
|
||||
originalPostContent: reads("post.cooked"),
|
||||
|
||||
post: reads("topic.post_stream.posts.firstObject"),
|
||||
post: computed("topic", function() {
|
||||
return this.store.createRecord(
|
||||
"post",
|
||||
this.topic.post_stream.posts.firstObject
|
||||
);
|
||||
}),
|
||||
|
||||
model: computed("post", "topic", function() {
|
||||
const post = this.post;
|
||||
post.topic = this.topic;
|
||||
|
||||
if (!post.topic) {
|
||||
post.set("topic", this.topic);
|
||||
}
|
||||
|
||||
return post;
|
||||
}),
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import Category from "discourse/models/category";
|
||||
import Topic from "discourse/models/topic";
|
||||
import { on } from "discourse-common/utils/decorators";
|
||||
import KnowledgeExplorer from "discourse/plugins/discourse-knowledge-explorer/discourse/models/knowledge-explorer";
|
||||
|
||||
|
@ -87,7 +88,7 @@ export default Ember.Controller.extend({
|
|||
|
||||
KnowledgeExplorer.getTopic(topicId).then(result => {
|
||||
this.setProperties({
|
||||
topic: result,
|
||||
topic: Topic.create(result),
|
||||
isTopicLoading: false
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { ajax } from "discourse/lib/ajax";
|
||||
import Topic from "discourse/models/topic";
|
||||
|
||||
function getTopic(id) {
|
||||
return ajax(`/t/${id}.json`);
|
||||
|
@ -20,7 +21,7 @@ export default {
|
|||
if (params.selectedTopic) {
|
||||
promise = promise.then(data => {
|
||||
return getTopic(params.selectedTopic).then(topic => {
|
||||
data.topic = topic;
|
||||
data.topic = Topic.create(topic);
|
||||
return data;
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue