From 820fe572ca87ace3b6d85dad6934b1e60c7c8a3c Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 11 Feb 2014 10:06:20 +1100 Subject: [PATCH] BUGFIX: phantom new and unread for category definition topics --- app/controllers/list_controller.rb | 5 +++++ lib/topic_query.rb | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rb index 6913ea6b862..79ad80cc5e2 100644 --- a/app/controllers/list_controller.rb +++ b/app/controllers/list_controller.rb @@ -40,6 +40,11 @@ class ListController < ApplicationController list_opts = build_topic_list_options list_opts.merge!(options) if options user = list_target_user + + if filter == :latest && params[:category].blank? + list_opts[:no_definitions] = true + end + list = TopicQuery.new(user, list_opts).public_send("list_#{filter}") list.more_topics_url = construct_url_with(list_opts) if Discourse.anonymous_filters.include?(filter) diff --git a/lib/topic_query.rb b/lib/topic_query.rb index 57dd477cf07..349703b2b42 100644 --- a/lib/topic_query.rb +++ b/lib/topic_query.rb @@ -240,8 +240,8 @@ class TopicQuery result = result.listable_topics.includes(category: :topic_only_relative_url) result = result.where('categories.name is null or categories.name <> ?', options[:exclude_category]).references(:categories) if options[:exclude_category] - # Don't include the category topic unless restricted to that category - if options[:category].blank? || options[:no_definitions] + # Don't include the category topics if excluded + if options[:no_definitions] result = result.where('COALESCE(categories.topic_id, 0) <> topics.id') end