FIX: On mobile jumping to replies was not working

This commit is contained in:
Robin Ward 2016-03-14 13:21:58 -04:00
parent 4b7046efa4
commit 7e97724341
2 changed files with 11 additions and 6 deletions

View File

@ -11,9 +11,7 @@ const DiscourseURL = Ember.Object.createWithMixins({
return _jumpScheduled;
},
/**
Jumps to a particular post in the stream
**/
// Jumps to a particular post in the stream
jumpToPost(postNumber, opts) {
const holderId = `#post_${postNumber}`;
const offset = () => {

View File

@ -348,12 +348,20 @@ createWidget('post-article', {
return rows;
},
_getTopicUrl() {
const post = this.findAncestorModel();
return post ? post.get('topic.url') : null;
},
toggleReplyAbove() {
const replyPostNumber = this.attrs.reply_to_post_number;
// jump directly on mobile
if (this.attrs.mobileView) {
DiscourseURL.jumpToPost(replyPostNumber);
const topicUrl = this._getTopicUrl();
if (topicUrl) {
DiscourseURL.routeTo(`${topicUrl}/${replyPostNumber}`);
}
return Ember.RSVP.Promise.resolve();
}
@ -361,8 +369,7 @@ createWidget('post-article', {
this.state.repliesAbove = [];
return Ember.RSVP.Promise.resolve();
} else {
const post = this.findAncestorModel();
const topicUrl = post ? post.get('topic.url') : null;
const topicUrl = this._getTopicUrl();
return this.store.find('post-reply-history', { postId: this.attrs.id }).then(posts => {
this.state.repliesAbove = posts.map((p) => {
p.shareUrl = `${topicUrl}/${p.post_number}`;