diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index f50fae5c3cd78d8433d7fd4ff26b3b069cc4a376..9912895e58722931a8ed39a08d3d03735555c9fc 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -27,7 +27,7 @@ class AspectsController < ApplicationController @selected_contacts = @aspects.map { |aspect| aspect.contacts }.flatten.uniq @aspect_ids = @aspects.map { |a| a.id } @posts = current_user.raw_visible_posts(:by_members_of => @aspect_ids, :type => 'StatusMessage', :order => session[:sort_order] + ' DESC').includes( - :comments, :likes, :dislikes).paginate(:page => params[:page], :per_page => 15, :order => session[:sort_order] + ' DESC') + :comments, :mentions, :likes, :dislikes).paginate(:page => params[:page], :per_page => 15, :order => session[:sort_order] + ' DESC') @fakes = PostsFake.new(@posts) @contact_count = current_user.contacts.count diff --git a/app/views/comments/_comment.html.haml b/app/views/comments/_comment.html.haml index 9fd2b83e136fffd47980e8429b2152fc6cab51ea..c9af008d7b0c3901c838fc86b8d2d961396f26a5 100644 --- a/app/views/comments/_comment.html.haml +++ b/app/views/comments/_comment.html.haml @@ -3,7 +3,7 @@ -# the COPYRIGHT file. %li.comment.posted{:data=>{:guid => comment.id}, :class => ("hidden" if(defined? hidden))} - - if current_user && (current_user.owns?(comment) || current_user.owns?(comment.post)) + - if current_user && (current_user.owns?(comment) || current_user.owns?(post)) .right.controls = link_to image_tag('deletelabel.png'), comment_path(comment), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete comment_delete", :title => t('delete') = person_image_link(comment.author) diff --git a/app/views/comments/_comments.haml b/app/views/comments/_comments.haml index 19f3cfa91fe9afc2c209f484d7f695807a298036..187d0aef7d46dd8ff5f0513e146b3108ba4e4ad0 100644 --- a/app/views/comments/_comments.haml +++ b/app/views/comments/_comments.haml @@ -10,14 +10,14 @@ = image_tag 'icons/spechbubble_2.png', :class => 'more_comments_icon' %b= comment_toggle(comments.size) -%ul.comments{:id => post_id, :class => ("hidden" if comments.size == 0 && !defined?(force_open) && !is_expanded)} +%ul.comments{:id => post.id, :class => ("hidden" if comments.size == 0 && !defined?(force_open) && !is_expanded)} -if comments.size > 3 .older_comments{:class => ("hidden inactive" if defined?(condensed) && condensed)} - = render :partial => 'comments/comment', :collection => comments[0..-4] - = render :partial => 'comments/comment', :collection => comments[-3, 3] + = render :partial => 'comments/comment', :collection => comments[0..-4], :locals => {:post => post} + = render :partial => 'comments/comment', :collection => comments[-3, 3], :locals => {:post => post} -else - = render :partial => 'comments/comment', :collection => comments + = render :partial => 'comments/comment', :collection => comments, :locals => {:post => post} - unless @commenting_disabled %li.comment.show - = new_comment_form(post_id, current_user) + = new_comment_form(post.id, current_user) diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 0d82dbcf4a374e2703a77e25b4eece42f3e8e77e..4da938b0b4fb4e3feb18f8e2fc522696ce199812 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -76,4 +76,4 @@ %div{:data=>{:guid=>@parent.id}} .likes_container = render "likes/likes", :post_id => @parent.id, :likes => @parent.likes, :dislikes => @parent.dislikes - = render "comments/comments", :post_id => @parent.id, :comments => @parent.comments, :always_expanded => true + = render "comments/comments", :post => @parent, :comments => @parent.comments, :always_expanded => true diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index eada69d5806b45f4c84f8405a8b66087610ef1a5..25d923381c61d8f4eb12b80ff9ffc15a23f6309d 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -44,4 +44,4 @@ /.likes_container / = render "likes/likes", :post_id => post.id, :likes => post.likes, :dislikes => post.dislikes, :current_user => current_user - = render "comments/comments", :post_id => post.id, :comments => post.comments, :current_user => current_user, :condensed => true, :commenting_disabled => (defined?(@commenting_disabled) && @commenting_disabled) + = render "comments/comments", :post => post, :comments => post.comments, :current_user => current_user, :condensed => true, :commenting_disabled => (defined?(@commenting_disabled) && @commenting_disabled) diff --git a/app/views/status_messages/show.html.haml b/app/views/status_messages/show.html.haml index 04e9bfdf0e0ea1f14048201f0d0c90a022d6865c..34cbfe9e00d43b8c5a1627c8aef2aa82cdaba453 100644 --- a/app/views/status_messages/show.html.haml +++ b/app/views/status_messages/show.html.haml @@ -29,4 +29,4 @@ = t('_comments') #status_message_stream.stream.show %div{:data=>{:guid=>@status_message.id}} - = render "comments/comments", :post_id => @status_message.id, :comments => @status_message.comments, :always_expanded => true + = render "comments/comments", :post => @status_message, :comments => @status_message.comments, :always_expanded => true diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb index 461db41f54508c1b7db118b6fbf6a59946c7cc97..f880a6188385bbcdb4d04fc999675fdce865ac4b 100644 --- a/lib/diaspora/user/querying.rb +++ b/lib/diaspora/user/querying.rb @@ -13,7 +13,7 @@ module Diaspora def raw_visible_posts(opts = {}) opts[:type] ||= ['StatusMessage', 'Photo'] opts[:limit] ||= 20 - opts[:order] ||= 'created_at DESC' + opts[:order] ||= 'updated_at DESC' opts[:order] = '`posts`.' + opts[:order] posts_from_others = Post.joins(:contacts).where(:contacts => {:user_id => self.id}) @@ -25,8 +25,8 @@ module Diaspora posts_from_self = posts_from_self.where(:aspects => {:id => opts[:by_members_of]}) end - post_ids = posts_from_others.select('posts.id').limit(opts[:limit]).order(opts[:order]).map{|p| p.id} - post_ids += posts_from_self.select('posts.id').limit(opts[:limit]).order(opts[:order]).map{|p| p.id} + post_ids = Post.connection.execute(posts_from_others.select('posts.id').limit(opts[:limit]).order(opts[:order]).to_sql).map{|r| r.first} + post_ids += Post.connection.execute(posts_from_self.select('posts.id').limit(opts[:limit]).order(opts[:order]).to_sql).map{|r| r.first} Post.where(:id => post_ids, :pending => false, :type => opts[:type]).select('DISTINCT `posts`.*').limit(opts[:limit]) end