Skip to content

Commit

Permalink
Forum: Fix custom pagination.
Browse files Browse the repository at this point in the history
  • Loading branch information
nottalulah committed May 12, 2024
1 parent 35a512d commit 09ca8db
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/forum_post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def quoted_response
end

def forum_topic_page
(ForumPost.where("topic_id = ? and created_at <= ?", topic_id, created_at).count / Danbooru.config.posts_per_page.to_f).ceil
(ForumPost.where("topic_id = ? and created_at <= ?", topic_id, created_at).count / CurrentUser.user.per_page.to_f).ceil
end

def is_original_post?(original_post_id = nil)
Expand Down
4 changes: 2 additions & 2 deletions app/models/forum_topic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ def create_mod_action_for_undelete
end

def page_for(post_id)
(forum_posts.where("id < ?", post_id).count / Danbooru.config.posts_per_page.to_f).ceil
(forum_posts.where("id < ?", post_id).count / CurrentUser.user.per_page.to_f).ceil
end

def last_page
(response_count / Danbooru.config.posts_per_page.to_f).ceil
(response_count / CurrentUser.user.per_page.to_f).ceil
end

# Delete all posts when the topic is deleted. Undelete all posts when the topic is undeleted.
Expand Down
2 changes: 1 addition & 1 deletion app/views/forum_topics/_listing.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<%= link_to topic.title, forum_topic_path(topic), class: "forum-post-link break-words" %>
<% end %>
<% if topic.response_count > Danbooru.config.posts_per_page %>
<% if topic.response_count > CurrentUser.user.per_page %>
<%= link_to "page #{topic.last_page}", forum_topic_path(topic, :page => topic.last_page), :class => "last-page" %>
<% end %>
<% end %>
Expand Down

0 comments on commit 09ca8db

Please sign in to comment.