Watching/Tracking old Topics

Now that I’ve looked at the code a bit, this would certainly be an awful lot easier!

At the moment, the “new” tab is sorted by “topic.bumped_at”, but filtered by “topic.created_at”. What’s the thinking behind this? It seems a little un-intuitive that topics don’t “drop off the bottom” of the list once they’re no longer declared new. What would be quite nice, at least for my forum, would be to filter them by “topic.bumped_at”.

Would there be any way for me to adapt the new/unread logic on my forum using a plugin, without having to hack around in the code? Or is there a best-practice way for patching the core code so that I can still apply updates?

Edit: I’ve come up with this plugin which works, but doesn’t apply the “new” badge to topics. Is the logic for that badge elsewhere?

# name: filter-new-bumped
# about: A super simple plugin to override the new_filter to use bumped_at instead of created_at
# version: 0.0.1
# authors: David Taylor

after_initialize do
	require_dependency 'topic_query'
	class ::TopicQuery
	  def self.new_filter(list, treat_as_new_topic_start_date)
	    list.where("topics.bumped_at >= :created_at", created_at: treat_as_new_topic_start_date)
	        .where("tu.last_read_post_number IS NULL")
	        .where("COALESCE(tu.notification_level, :tracking) >= :tracking", tracking: TopicUser.notification_levels[:tracking])
	  end
	end
end