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; return _jumpScheduled;
}, },
/** // Jumps to a particular post in the stream
Jumps to a particular post in the stream
**/
jumpToPost(postNumber, opts) { jumpToPost(postNumber, opts) {
const holderId = `#post_${postNumber}`; const holderId = `#post_${postNumber}`;
const offset = () => { const offset = () => {

View File

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