Skip to content

Commit

Permalink
update pagination logic when searching to add videos to a playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunkyProgrammer committed Apr 29, 2024
1 parent eda7444 commit 661d197
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/invidious/routes/playlists.cr
Expand Up @@ -254,17 +254,20 @@ module Invidious::Routes::Playlists

begin
query = Invidious::Search::Query.new(env.params.query, :playlist, region)
items = query.process.select(SearchVideo).map(&.as(SearchVideo))
processed_query = query.process
total_items = processed_query.size
items = processed_query.select(SearchVideo).map(&.as(SearchVideo))
rescue ex
items = [] of SearchVideo
total_items = 0
end

# Pagination
query_encoded = URI.encode_www_form(query.try &.text || "", space_to_plus: true)
page_nav_html = Frontend::Pagination.nav_numeric(locale,
base_url: "/add_playlist_items?list=#{playlist.id}&q=#{query_encoded}",
current_page: page,
show_next: (items.size >= 20)
show_next: (total_items >= 20)
)

env.set "add_playlist_items", plid
Expand Down

0 comments on commit 661d197

Please sign in to comment.