diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 14ac980..5a8b3f8 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 6b9f52f..0e3b3ec 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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)