From c412d74369a4fbc0dbf044ff8ee68c6b7c9bb1fb Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 26 Aug 2014 12:00:16 +1000 Subject: [PATCH] HACK: suppress "1 reply" when directly below for quotes posts --- app/assets/javascripts/discourse/models/topic.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/models/topic.js b/app/assets/javascripts/discourse/models/topic.js index 43fb4f526f9..5a0d372237d 100644 --- a/app/assets/javascripts/discourse/models/topic.js +++ b/app/assets/javascripts/discourse/models/topic.js @@ -293,13 +293,21 @@ Discourse.Topic = Discourse.Model.extend({ // Is the reply to a post directly below it? isReplyDirectlyBelow: function(post) { var posts = this.get('postStream.posts'); + var postNumber = post.get('post_number'); if (!posts) return; var postBelow = posts[posts.indexOf(post) + 1]; - // If the post directly below's reply_to_post_number is our post number, it's - // considered directly below. - return postBelow && postBelow.get('reply_to_post_number') === post.get('post_number'); + // If the post directly below's reply_to_post_number is our post number or we are quoted, + // it's considered directly below. + // + // TODO: we don't carry information about quoting, this leaves this code fairly fragile + // instead we should start shipping quote meta data with posts, but this will add at least + // 1 query to the topics page + // + return postBelow && (postBelow.get('reply_to_post_number') === postNumber || + postBelow.get('cooked').indexOf('data-post="'+ postNumber + '"') >= 0 + ); }, excerptNotEmpty: Em.computed.notEmpty('excerpt'),