FIX: Jump to embedded was not working when the post was far away

This commit is contained in:
Robin Ward 2016-02-22 15:58:08 -05:00
parent 026bba1876
commit acc20c87b2
2 changed files with 14 additions and 4 deletions

View File

@ -18,7 +18,7 @@ createWidget('post-link-arrow', {
},
click() {
DiscourseURL.jumpToPost(this.attrs.post_number);
DiscourseURL.routeTo(this.attrs.shareUrl);
}
});
@ -32,7 +32,7 @@ export default createWidget('embedded-post', {
h('div.topic-body', [
h('div.topic-meta-data', [
this.attach('poster-name', attrs),
this.attach('post-link-arrow', { above: state.above, post_number: attrs.post_number })
this.attach('post-link-arrow', { above: state.above, shareUrl: attrs.shareUrl })
]),
new RawHtml({html: `<div class='cooked'>${attrs.cooked}</div>`})
])

View File

@ -278,8 +278,13 @@ createWidget('post-contents', {
return;
}
const topic = this.findAncestorModel().get('topic');
const topicUrl = topic.get('url');
return this.store.find('post-reply', { postId: this.attrs.id }).then(posts => {
this.state.repliesBelow = posts.map(transformBasicPost);
this.state.repliesBelow = posts.map(p => {
p.shareUrl = `${topicUrl}/${p.post_number}`;
return transformBasicPost(p);
});
});
},
@ -351,8 +356,13 @@ createWidget('post-article', {
this.state.repliesAbove = [];
return Ember.RSVP.Promise.resolve();
} else {
const topic = this.findAncestorModel().get('topic');
const topicUrl = topic.get('url');
return this.store.find('post-reply-history', { postId: this.attrs.id }).then(posts => {
this.state.repliesAbove = posts.map(transformBasicPost);
this.state.repliesAbove = posts.map((p) => {
p.shareUrl = `${topicUrl}/${p.post_number}`;
return transformBasicPost(p);
});
});
}
},