diff options
| author | Brahim Hadriche <brahim.hadriche@gmail.com> | 2023-03-01 22:08:19 -0500 |
|---|---|---|
| committer | Brahim Hadriche <brahim.hadriche@gmail.com> | 2023-03-01 22:08:19 -0500 |
| commit | 27bf4d02a185e6750cdecdc4f1c169b0723dbbf5 (patch) | |
| tree | e00d5686a74c4b798a387f91295ce54312303812 | |
| parent | 15e9510ab212ac1f8b6bc2a5a3e83ebc4ba1fe90 (diff) | |
| download | invidious-27bf4d02a185e6750cdecdc4f1c169b0723dbbf5.tar.gz invidious-27bf4d02a185e6750cdecdc4f1c169b0723dbbf5.tar.bz2 invidious-27bf4d02a185e6750cdecdc4f1c169b0723dbbf5.zip | |
PR nursing
| -rw-r--r-- | src/invidious/routes/api/v1/authenticated.cr | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/invidious/routes/api/v1/authenticated.cr b/src/invidious/routes/api/v1/authenticated.cr index dc86bb3c..a20d23d0 100644 --- a/src/invidious/routes/api/v1/authenticated.cr +++ b/src/invidious/routes/api/v1/authenticated.cr @@ -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 |
