FIX: jump to original post when expanded posts are collasped
This commit is contained in:
parent
73dea4e7eb
commit
d24c35012d
|
@ -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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -299,7 +299,7 @@ createWidget('post-contents', {
|
||||||
|
|
||||||
const repliesBelow = state.repliesBelow;
|
const repliesBelow = state.repliesBelow;
|
||||||
if (repliesBelow.length) {
|
if (repliesBelow.length) {
|
||||||
result.push(h('section.embedded-posts.bottom', [
|
result.push(h('section.embedded-posts.bottom', [
|
||||||
repliesBelow.map(p => {
|
repliesBelow.map(p => {
|
||||||
return this.attach('embedded-post', p, { model: this.store.createRecord('post', p) });
|
return this.attach('embedded-post', p, { model: this.store.createRecord('post', p) });
|
||||||
}),
|
}),
|
||||||
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue