FIX: convert topic & post models to ember object.

This commit is contained in:
Vinoth Kannan 2020-03-03 10:34:20 +05:30
parent 09da5dd7bb
commit cd3b58358e
3 changed files with 15 additions and 4 deletions

View File

@ -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;
}),

View File

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

View File

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