forum: optimize unread forum topics on forum index.
Avoid doing one SQL query per topic when checking for new topics on the forum index. This also changes it so that forum topics aren't always marked as new for anonymous users.
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
|
||||
<div class="section">
|
||||
<h2>Forum Topics</h2>
|
||||
<%= render "forum_topics/listing", :forum_topics => @dashboard.forum_topics %>
|
||||
<%= render "forum_topics/listing", forum_topics: @dashboard.forum_topics, read_forum_topics: @dashboard.forum_topics.read_by_user(CurrentUser.user) %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<span class="sticky">Sticky:</span>
|
||||
<% end %>
|
||||
|
||||
<% unless topic.read_by?(CurrentUser.user) %>
|
||||
<% if CurrentUser.is_member? && new_forum_topic?(topic, read_forum_topics) %>
|
||||
<span class="new">NEW</span>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<%= ForumTopic::CATEGORIES.map {|id, name| link_to_unless_current(name, forum_topics_path(:search => {:category_id => id}))}.join(", ").html_safe %>
|
||||
</p>
|
||||
|
||||
<%= render "listing", :forum_topics => @forum_topics %>
|
||||
<%= render "listing", forum_topics: @forum_topics, read_forum_topics: @read_forum_topics %>
|
||||
|
||||
<%= numbered_paginator(@forum_topics) %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user