FIX: Overwriting more computed properties

This commit is contained in:
Robin Ward 2020-07-16 13:22:13 -04:00
parent 01cd371be5
commit 766cb24989
2 changed files with 10 additions and 8 deletions

View File

@ -407,9 +407,7 @@ createWidget("post-contents", {
result.push(
h("section.embedded-posts.bottom", [
repliesBelow.map(p => {
return this.attach("embedded-post", p, {
model: this.store.createRecord("post", p)
});
return this.attach("embedded-post", p, { model: p.asPost });
}),
this.attach("button", {
title: "post.collapse",
@ -449,8 +447,10 @@ createWidget("post-contents", {
.find("post-reply", { postId: this.attrs.id })
.then(posts => {
this.state.repliesBelow = posts.map(p => {
p.shareUrl = `${topicUrl}/${p.post_number}`;
return transformWithCallbacks(p);
let result = transformWithCallbacks(p);
result.shareUrl = `${topicUrl}/${p.post_number}`;
result.asPost = this.store.createRecord("post", p);
return result;
});
});
},
@ -565,7 +565,7 @@ createWidget("post-article", {
if (state.repliesAbove.length) {
const replies = state.repliesAbove.map(p => {
return this.attach("embedded-post", p, {
model: this.store.createRecord("post", p),
model: p.asPost,
state: { above: true }
});
});

View File

@ -20,7 +20,8 @@ function postStreamTest(name, attrs) {
postStreamTest("basics", {
posts() {
const site = this.container.lookup("site:main");
const topic = Topic.create({ details: { created_by: { id: 123 } } });
const topic = Topic.create();
topic.set("details.created_by", { id: 123 });
return [
Post.create({
topic,
@ -118,7 +119,8 @@ postStreamTest("basics", {
postStreamTest("deleted posts", {
posts() {
const topic = Topic.create({ details: { created_by: { id: 123 } } });
const topic = Topic.create();
topic.set("details.created_by", { id: 123 });
return [
Post.create({
topic,