Compare commits

...

2 Commits

Author SHA1 Message Date
ChunkyProgrammer
13cc97d7d9
Merge 661d1977e9 into eda7444ca4 2024-04-29 22:57:59 +00:00
ChunkyProgrammer
661d1977e9 update pagination logic when searching to add videos to a playlist 2024-04-29 18:57:42 -04:00

View File

@ -254,9 +254,12 @@ module Invidious::Routes::Playlists
begin begin
query = Invidious::Search::Query.new(env.params.query, :playlist, region) 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 rescue ex
items = [] of SearchVideo items = [] of SearchVideo
total_items = 0
end end
# Pagination # Pagination
@ -264,7 +267,7 @@ module Invidious::Routes::Playlists
page_nav_html = Frontend::Pagination.nav_numeric(locale, page_nav_html = Frontend::Pagination.nav_numeric(locale,
base_url: "/add_playlist_items?list=#{playlist.id}&q=#{query_encoded}", base_url: "/add_playlist_items?list=#{playlist.id}&q=#{query_encoded}",
current_page: page, current_page: page,
show_next: (items.size >= 20) show_next: (total_items >= 20)
) )
env.set "add_playlist_items", plid env.set "add_playlist_items", plid