pagination: refactor page limits.
Refactor page limits to a) be explicitly listed in the User class (not hidden away in the Danbooru config) and b) explicitly depend on the CurrentUser (not implicitly by way of Danbooru.config.max_numbered_pages).
This commit is contained in:
@@ -380,6 +380,16 @@ class User < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def page_limit(level)
|
||||
if level >= User::Levels::PLATINUM
|
||||
5000
|
||||
elsif level == User::Levels::GOLD
|
||||
2000
|
||||
else
|
||||
1000
|
||||
end
|
||||
end
|
||||
|
||||
def tag_query_limit(level)
|
||||
if level >= User::Levels::BUILDER
|
||||
Float::INFINITY
|
||||
@@ -484,6 +494,10 @@ class User < ApplicationRecord
|
||||
@upload_limit ||= UploadLimit.new(self)
|
||||
end
|
||||
|
||||
def page_limit
|
||||
User.page_limit(level)
|
||||
end
|
||||
|
||||
def tag_query_limit
|
||||
User.tag_query_limit(level)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user