Show available actions on embed error page #4760
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
If you have privacyRedirect installed in your browser, any embedded youtube videos are automatically replaced by an invidious equivalent on pages you visit. The trouble is, often embeds don't always work - if 1/ the selected instance is down; 2/ the video is blocked or similar.
Current flow
If you particularly want to watch the video, you might right-click the iframe, click open in new tab, then replace the
/embed/
part of the url with/watch?v=
- or replace the domain withyoutube.com
to see the youtube version of it (but still as an embed)Desired flow
It would be great if you had the same actions available on regular video error pages (switch instance / watch on youtube / refresh)
Caveats
It's worth noting that different browsers handle links inside iframes differently; eg. firefox often prompts you to open the link in a new tab - which IMO is ok, because if you are interested enough in the video to want to watch it, you would probably prefer to at least have this automatically, rather than doing it manually?
Chrome, on the other hand, doesn't even give you the option to "open frame in new tab" when you right click it, but it does seem to follow urls within the frame
Summary of changes in PR
request_path.starts_with?("/embed")
check toerror_redirect_helper
error_redirect_helper
ContextWithPreferences
andtest_env
helpers to help with test setup/compilationThe first point is obviously the main functional change, and the latter 3 are IMO code quality improvements (so they can be modified/removed if they are not helpful here)
Testing
I don't have this set up fully e2e locally so haven't checked this fully, but I found the unit tests went a decent way to verifying the behaviour I wanted