Removed the purging of the query parameters

This commit is contained in:
RadoslavL 2023-10-26 11:30:12 +03:00
parent 995df2d296
commit e8c2388589
3 changed files with 14 additions and 5 deletions

View File

@ -32,14 +32,22 @@ function button_press(){
// On the first page, the stored continuation token is null.
if (prev_ctoken === null) {
sessionStorage.removeItem(CONT_CACHE_KEY);
window.location.href = window.location.href.split('?')[0];
let url = window.location.href.split('?')[0];
let params = window.location.href.split('?')[1];
let url_params = new URLSearchParams(params);
url_params.delete('continuation');
window.location.href = `${url}?${url_params.toString()}`;
return;
}
sessionStorage.setItem(CONT_CACHE_KEY, JSON.stringify(prev_data));
let url = window.location.href.split('?')[0];
let params = window.location.href.split('?')[1];
let url_params = new URLSearchParams(params);
url_params.set("continuation", prev_ctoken);
window.location.href = `${window.location.pathname}?continuation=${prev_ctoken}`;
window.location.href = `${url}?${url_params.toString()}`;
};
addEventListener('DOMContentLoaded', function(){

View File

@ -90,7 +90,7 @@ module Invidious::Frontend::Pagination
end
end
def nav_ctoken(locale : String?, *, base_url : String | URI, ctoken : String?, first_page : Bool)
def nav_ctoken(locale : String?, *, base_url : String | URI, ctoken : String?, first_page : Bool, params : URI::Params)
return String.build do |str|
str << %(<div class="h-box">\n)
str << %(<div class="page-nav-container flexible">\n)
@ -106,8 +106,8 @@ module Invidious::Frontend::Pagination
str << %(<div class="page-next-container flex-right">)
if !ctoken.nil?
params_next = URI::Params{"continuation" => ctoken}
url_next = HttpServer::Utils.add_params_to_url(base_url, params_next)
params["continuation"] = ctoken
url_next = HttpServer::Utils.add_params_to_url(base_url, params)
self.next_page(str, locale, url_next.to_s)
end

View File

@ -22,6 +22,7 @@
base_url: relative_url,
ctoken: next_continuation,
first_page: continuation.nil?,
params: env.params.query,
)
%>