Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend: Add a first page and previous page buttons for channel navigation #4123

Merged
merged 22 commits into from
Feb 26, 2025

Conversation

RadoslavL
Copy link
Contributor

@RadoslavL RadoslavL commented Sep 27, 2023

Fixes: #660
I want to be awarded the bounty associated to the issue this PR is fixing.

This works in all channel content categories (videos, shorts, playlists, etc). I also added translations of the button text to a couple of locales.

Update: The code now supports both a previous page button (using Javascript) and a first page button. When the browser doesn't support Javascript, the first page button is used instead of the previous page button. All credit for the previous page button goes out to @syeopite for providing the Javascript code. (I modified it a bit to make the variable names the same as the ones used in my old code, but the structure is exactly the same.)

@RadoslavL RadoslavL requested review from SamantazFox and a team as code owners September 27, 2023 08:43
@syeopite
Copy link
Member

I don't think adding a previous page button is possible

You actually can! It's just a bit more complicated than a first page button though.

As said in the issue, you'll just have to cache the continuation tokens. Though something that's not mentioned is that you'll probably also need a sanity check on the continuation tokens if you aren't caching it in the URL due to the browsers "back" feature.

I have a branch that implements this functionality through JS and session storage here. Feel free to take what you want in there if you'd like to implement this 😁

@RadoslavL
Copy link
Contributor Author

I don't think adding a previous page button is possible

You actually can! It's just a bit more complicated than a first page button though.

As said in the issue, you'll just have to cache the continuation tokens. Though something that's not mentioned is that you'll probably also need a sanity check on the continuation tokens if you aren't caching it in the URL due to the browsers "back" feature.

I have a branch that implements this functionality through JS and session storage here. Feel free to take what you want in there if you'd like to implement this 😁

Yes, I knew there was a way to do it with cookies and/or session storage. The main problem with that is that this requires JavaScript. I thought Invidious was supposed to be JS free, that's why I never considered that solution. Thank you for the reply! I will see if I can implement this using JavaScript.

@syeopite
Copy link
Member

Invidious is supposed to work without Javascript but (at least in my opinion) pure quality of life features can be safely locked behind JS. A previous page button would certainly fall under that category.

@RadoslavL
Copy link
Contributor Author

RadoslavL commented Sep 28, 2023

@syeopite I created the previous page button in my fork. Do I create another PR for the new code, or wait for this one to get merged?

Edit: I noticed that at some point the URI becomes too long and Invidious just outputs "414 URI Too Long". I don't think there is a way around that. I think I might be able to make a solution, but it's only an idea at this point.

Update: I got it working. There is more to do, but it will probably work.

Update 2: This isn't the solution. I got a "431 Request Header Fields Too Large" error. The array of continuations becomes quite large.

@syeopite
Copy link
Member

@syeopite I created the previous page button in my fork. Do I create another PR for the new code, or wait for this one to get merged?

You can just put it into this PR.

Update...

Exactly. If I'm not mistake caching the continuation tokens client side with Javascript is really the only way to accomplish this. Sending the data back and forth through various means will not only impact performance significantly, you'll also reach the maximum length limitations when you aren't caching it in the body directly.

Unless you are caching it in session storage I'll recommend just keeping with the first page button.

If you are going to cache it in session storage then feel free to just integrate my implementation (you can have the bounty) or something like it into this PR and do something like the following to merge it together smoothly:

  1. Make the previous page button optional through the preferences page
  2. Use a first page button when the aforementioned is turned off or when JavaScript is disabled

…ween the first page and previous page buttons possible
@RadoslavL RadoslavL changed the title Added a first page button for channel navigation Added a first page and previous page buttons for channel navigation Sep 30, 2023
@syeopite syeopite self-requested a review September 30, 2023 16:10
@RadoslavL
Copy link
Contributor Author

RadoslavL commented Sep 30, 2023

@syeopite I added the user preferences option, that chooses which navigation button to use. You can now switch between them.

@RadoslavL RadoslavL changed the title Added a first page and previous page buttons for channel navigation Add a first page and previous page buttons for channel navigation Oct 31, 2023
@RadoslavL RadoslavL changed the title Add a first page and previous page buttons for channel navigation Frontend: Add a first page and previous page buttons for channel navigation Oct 31, 2023
@RadoslavL
Copy link
Contributor Author

Bump.

@github-actions github-actions bot added the stale label Apr 7, 2024
@iv-org iv-org deleted a comment from github-actions bot Apr 7, 2024
@syeopite syeopite removed the stale label Apr 7, 2024
@github-actions github-actions bot added the stale label Jul 22, 2024
@syeopite syeopite removed the stale label Jul 22, 2024
@iv-org iv-org deleted a comment from github-actions bot Jul 22, 2024
@github-actions github-actions bot added the stale label Oct 21, 2024
@RadoslavL
Copy link
Contributor Author

I'm pretty sure it's still applicable.

@iv-org iv-org deleted a comment from github-actions bot Oct 31, 2024
@github-actions github-actions bot removed the stale label Nov 9, 2024
@syeopite syeopite merged commit f95f87e into iv-org:master Feb 26, 2025
6 of 7 checks passed
@RadoslavL
Copy link
Contributor Author

RadoslavL commented Mar 7, 2025

If applicable, I'd like to receive the bounty associated with this pull request.

@syeopite
Copy link
Member

syeopite commented Mar 7, 2025

@TheFrenchGhosty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No "Previous Page" on the playlists list
3 participants