FIX: If editing a reply, the quote button should target the post it was

a reply to, not the post you're editing.
This commit is contained in:
Robin Ward 2014-08-08 16:36:53 -04:00
parent c410da4f7f
commit dc260110fa

View file

@ -305,8 +305,25 @@ Discourse.Composer = Discourse.Model.extend({
}, },
importQuote: function() { importQuote: function() {
var postStream = this.get('topic.postStream'),
postId = this.get('post.id');
if (!postId && postStream) {
postId = postStream.get('firstPostId');
}
// If we're editing a post, fetch the reply when importing a quote
if (this.get('editingPost')) {
var replyToPostNumber = this.get('post.reply_to_post_number');
if (replyToPostNumber) {
var replyPost = postStream.get('posts').findBy('post_number', replyToPostNumber);
if (replyPost) {
postId = replyPost.get('id');
}
}
}
// If there is no current post, use the post id from the stream // If there is no current post, use the post id from the stream
var postId = this.get('post.id') || this.get('topic.postStream.firstPostId');
if (postId) { if (postId) {
this.set('loading', true); this.set('loading', true);
var composer = this; var composer = this;