FIX: jump to original post when expanded posts are collasped

This commit is contained in:
Arpit Jalan 2018-01-19 18:01:54 +05:30
parent 73dea4e7eb
commit d24c35012d
2 changed files with 12 additions and 4 deletions

View File

@ -71,7 +71,7 @@ export const ButtonClass = {
if (attrs.sendActionEvent) { if (attrs.sendActionEvent) {
return this.sendWidgetAction(attrs.action, e); return this.sendWidgetAction(attrs.action, e);
} }
return this.sendWidgetAction(attrs.action); return this.sendWidgetAction(attrs.action, attrs.actionParam);
} }
}; };

View File

@ -307,6 +307,7 @@ createWidget('post-contents', {
title: 'post.collapse', title: 'post.collapse',
icon: 'chevron-up', icon: 'chevron-up',
action: 'toggleRepliesBelow', action: 'toggleRepliesBelow',
actionParam: 'true',
className: 'btn collapse-up' className: 'btn collapse-up'
}) })
])); ]));
@ -315,9 +316,12 @@ createWidget('post-contents', {
return result; return result;
}, },
toggleRepliesBelow() { toggleRepliesBelow(goToPost = 'false') {
if (this.state.repliesBelow.length) { if (this.state.repliesBelow.length) {
this.state.repliesBelow = []; this.state.repliesBelow = [];
if (goToPost === 'true') {
DiscourseURL.routeTo(`${this.attrs.topicUrl}/${this.attrs.post_number}`);
}
return; return;
} }
@ -389,6 +393,7 @@ createWidget('post-article', {
title: 'post.collapse', title: 'post.collapse',
icon: 'chevron-down', icon: 'chevron-down',
action: 'toggleReplyAbove', action: 'toggleReplyAbove',
actionParam: 'true',
className: 'btn collapse-down' className: 'btn collapse-down'
}), }),
replies replies
@ -404,7 +409,7 @@ createWidget('post-article', {
return post ? post.get('topic.url') : null; return post ? post.get('topic.url') : null;
}, },
toggleReplyAbove() { toggleReplyAbove(goToPost = 'false') {
const replyPostNumber = this.attrs.reply_to_post_number; const replyPostNumber = this.attrs.reply_to_post_number;
// jump directly on mobile // jump directly on mobile
@ -418,6 +423,9 @@ createWidget('post-article', {
if (this.state.repliesAbove.length) { if (this.state.repliesAbove.length) {
this.state.repliesAbove = []; this.state.repliesAbove = [];
if (goToPost === 'true') {
DiscourseURL.routeTo(`${this.attrs.topicUrl}/${this.attrs.post_number}`);
}
return Ember.RSVP.Promise.resolve(); return Ember.RSVP.Promise.resolve();
} else { } else {
const topicUrl = this._getTopicUrl(); const topicUrl = this._getTopicUrl();