diff --git a/app/assets/javascripts/discourse/views/topic_view.js b/app/assets/javascripts/discourse/views/topic_view.js index f95adddc6b0..d62733c6b5e 100644 --- a/app/assets/javascripts/discourse/views/topic_view.js +++ b/app/assets/javascripts/discourse/views/topic_view.js @@ -346,7 +346,6 @@ Discourse.TopicView.reopenClass({ var header = $('header'); var title = $('#topic-title'); var expectedOffset = title.height() - header.find('.contents').height(); - console.log(expectedOffset); if (expectedOffset < 0) { expectedOffset = 0; diff --git a/lib/topic_view.rb b/lib/topic_view.rb index e0d5d7e0aac..dad6767c173 100644 --- a/lib/topic_view.rb +++ b/lib/topic_view.rb @@ -86,14 +86,23 @@ class TopicView @topic.title end - def summary + def desired_post + return @desired_post if @desired_post.present? return nil if posts.blank? - Summarize.new(posts.first.cooked).summary + + @desired_post = posts.detect {|p| p.post_number == @post_number.to_i} + @desired_post ||= posts.first + @desired_post + end + + def summary + return nil if desired_post.blank? + Summarize.new(desired_post.cooked).summary end def image_url - return nil if posts.blank? - posts.first.user.small_avatar_url + return nil if desired_post.blank? + desired_post.user.small_avatar_url end def filter_posts(opts = {}) diff --git a/spec/components/topic_view_spec.rb b/spec/components/topic_view_spec.rb index f8f8ac51e8c..a12d4a14ea4 100644 --- a/spec/components/topic_view_spec.rb +++ b/spec/components/topic_view_spec.rb @@ -257,22 +257,26 @@ describe TopicView do it "snaps to the lower boundary" do near_view = topic_view_near(p1) + near_view.desired_post.should == p1 near_view.posts.should == [p1, p2, p3] end it "snaps to the upper boundary" do near_view = topic_view_near(p5) + near_view.desired_post.should == p5 near_view.posts.should == [p2, p3, p5] end it "returns the posts in the middle" do near_view = topic_view_near(p2) + near_view.desired_post.should == p2 near_view.posts.should == [p1, p2, p3] end it "returns deleted posts to an admin" do coding_horror.admin = true near_view = topic_view_near(p3) + near_view.desired_post.should == p3 near_view.posts.should == [p2, p3, p4] end