when showing another user's threads, don't include story threads
This commit is contained in:
parent
d6a29c8954
commit
5129733b04
|
@ -258,7 +258,8 @@ class CommentsController < ApplicationController
|
|||
@cur_url = "/threads"
|
||||
end
|
||||
|
||||
thread_ids = @showing_user.recent_threads(20)
|
||||
thread_ids = @showing_user.recent_threads(20,
|
||||
include_submitted_stories = !!(@user && @user.id == @showing_user.id))
|
||||
|
||||
comments = Comment.where(
|
||||
:thread_id => thread_ids
|
||||
|
|
|
@ -252,11 +252,11 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def recent_threads(amount)
|
||||
def recent_threads(amount, include_submitted_stories = false)
|
||||
thread_ids = self.comments.group(:thread_id).order('MAX(created_at) DESC').
|
||||
limit(amount).pluck(:thread_id)
|
||||
|
||||
if self.show_submitted_story_threads
|
||||
if include_submitted_stories && self.show_submitted_story_threads
|
||||
thread_ids += Comment.joins(:story).
|
||||
where(:stories => { :user_id => self.id }).group(:thread_id).
|
||||
order("MAX(comments.created_at) DESC").limit(amount).pluck(:thread_id)
|
||||
|
|
Loading…
Reference in a new issue