mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
PR nursing
This commit is contained in:
parent
15e9510ab2
commit
27bf4d02a1
1 changed files with 4 additions and 3 deletions
|
@ -58,15 +58,16 @@ module Invidious::Routes::API::V1::Authenticated
|
|||
env.response.content_type = "application/json"
|
||||
user = env.get("user").as(User)
|
||||
|
||||
page = env.params.query["page"]?.try &.to_i?
|
||||
page = env.params.query["page"]?.try &.to_i?.try &.clamp(0, Int32::MAX)
|
||||
page ||= 1
|
||||
|
||||
max_results = env.params.query["max_results"]?.try &.to_i?.try &.clamp(0, MAX_ITEMS_PER_PAGE)
|
||||
max_results ||= user.preferences.max_results
|
||||
max_results ||= CONFIG.default_user_preferences.max_results
|
||||
|
||||
if user.watched[(page - 1) * max_results]?
|
||||
watched = user.watched.reverse[(page - 1) * max_results, max_results]
|
||||
start_index = (page - 1) * max_results
|
||||
if user.watched[start_index]?
|
||||
watched = user.watched.reverse[start_index, max_results]
|
||||
end
|
||||
watched ||= [] of String
|
||||
|
||||
|
|
Loading…
Reference in a new issue