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

Use navigate instead of resolver #5823

Merged
merged 2 commits into from
Aug 13, 2024

Conversation

ilteoood
Copy link
Contributor

@ilteoood ilteoood commented Jul 23, 2024

Changes
In the routes, use the Navigate element instead of redirect resolver

Issues
Fixes jellyfin/jellyfin-tizen#279

@ilteoood ilteoood requested a review from a team as a code owner July 23, 2024 08:48
src/apps/experimental/routes/routes.tsx Outdated Show resolved Hide resolved
src/apps/stable/routes/routes.tsx Outdated Show resolved Hide resolved
@dmitrylyzo
Copy link
Contributor

FYI, we backport from the release branch to master, so other PR may be closed.

Does this fix the Tizen issue? I mean, have you tested this?

@dmitrylyzo dmitrylyzo added bug Something isn't working stable backport Backport into the next stable release p: tizen This PR or issue mainly concerns Tizen clients labels Jul 23, 2024
@dmitrylyzo dmitrylyzo added this to the v10.9.9 milestone Jul 23, 2024
@ilteoood
Copy link
Contributor Author

Yes, yesterday before opening the pr. My patched version is the one I'm running on the tv now.

@dmitrylyzo dmitrylyzo changed the title Fix/routing-loader fix: use navigate instead of resolver Jul 23, 2024
@thornbill
Copy link
Member

I'm curious what is the underlying issue with using redirect? Is it using something internally that we fail to polyfill?

@ilteoood
Copy link
Contributor Author

I'm curious what is the underlying issue with using redirect? Is it using something internally that we fail to polyfill?

It seems to be an odd internal behavior of the router: on tizen, instead of looking for the resolver, it checks just for the element property and then throws the error.
Additionally, looking at the official documentation seems that redirect should be used when handling http calls. In other scenarios, the Navigate is the way to go

@dmitrylyzo
Copy link
Contributor

dmitrylyzo commented Jul 23, 2024

Previously (before react-router) on Tizen 2.x (WebKit) we had an issue where the popstate event was triggered on page load, making the site think we had performed a back action.
Could it be related?

@ilteoood
Copy link
Contributor Author

I don't think so, this is more a library specific implementation rather than issue with the js engine itself

@ilteoood
Copy link
Contributor Author

ilteoood commented Jul 23, 2024

Here is the piece of code that is triggering it: https://github.com/remix-run/react-router/blob/0f2b167e9b862d5e6b3425438787c8e7b39197f4/packages/react-router/lib/hooks.tsx#L450

As you can see only element, component and lazy are checked. No loader

@ilteoood
Copy link
Contributor Author

ilteoood commented Jul 27, 2024

Hi @thornbill, is this ready to be merged or do I need to do something more?

@ilteoood
Copy link
Contributor Author

ilteoood commented Aug 1, 2024

Ping @thornbill

@thornbill
Copy link
Member

You really haven't explained why this is an issue for Tizen. The code you link to appears to only print a developer warning and looking at the message

This means it will render an with a null value by default resulting in an "empty" page.

it describes the behavior we want to happen. Also if you look at the react-router examples, you can see they have an authentication example that our code is based on (a loader returning a redirect).

@ilteoood
Copy link
Contributor Author

ilteoood commented Aug 3, 2024

@thornbill
The issue is explained in the original issue jellyfin/jellyfin-tizen#279.
It is an issue because it doesn't load the login screen.
Additionally, on the exaple you pasted I don't see a redirect but just an object instead of an http call. In fact, according to the official doc, it should be used to provide data to the route: https://reactrouter.com/en/main/route/loader, which is not our scenario.

@thornbill
Copy link
Member

My question is why is this only an issue for Tizen. If the problem was that react router doesn't support what we are doing for with the redirect then it wouldn't work anywhere.

@ilteoood
Copy link
Contributor Author

ilteoood commented Aug 5, 2024

Honestly speaking I don't know. The Tizen version I'm using is very old and the peculiarity of its engine implementation could have some bugs that can be hardly reproduced elsewhere. This would not be a new thing, since even in this repo there are some patches just for this platform.
e.g. https://github.com/jellyfin/jellyfin-web/blob/master/src/legacy/patchHeaders.js

@ilteoood
Copy link
Contributor Author

ilteoood commented Aug 5, 2024

BTW, are we seriously spending weeks discussing on a PR of 2 lines of code (repeated 2 times), that changes stuff following the library's best practice?
Version 10.9.9 has been released today and I'll need to manually patch it again to make it work on my TV.

@ilteoood
Copy link
Contributor Author

ilteoood commented Aug 5, 2024

Looking it a bit deeper it could be that my tizen version doesn't fully support the header or the response classes to do redirects.
Here is the implementation I checked: https://github.com/remix-run/react-router/blob/55c18bfc8e20417204cce5ecda88fe03520ad257/packages/router/utils.ts#L1615

I'm supposing it because jellyfin already has a patch for the headers constructor for tizen. Unfortunately I'm not 100 sure about it because for my tizen version there isn't any emulator and test each time on the TV is extremely painful.

@thornbill thornbill modified the milestones: v10.9.9, v10.10.0, v10.9.10 Aug 5, 2024
@ilteoood
Copy link
Contributor Author

ilteoood commented Aug 11, 2024

@thornbill Another user has the same issue: jellyfin/jellyfin-tizen#279 (comment)

Can we consider merging this?

Copy link

sonarcloud bot commented Aug 13, 2024

@thornbill thornbill merged commit 2e4e405 into jellyfin:release-10.9.z Aug 13, 2024
11 checks passed
@thornbill thornbill changed the title fix: use navigate instead of resolver Use navigate instead of resolver Aug 13, 2024
thornbill pushed a commit that referenced this pull request Aug 13, 2024
Use navigate instead of resolver

Original-merge: 2e4e405

Merged-by: thornbill <[email protected]>

Backported-by: thornbill <[email protected]>
@jellyfin-bot jellyfin-bot removed the stable backport Backport into the next stable release label Aug 13, 2024
@ilteoood ilteoood deleted the fix/routing-loader branch August 13, 2024 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p: tizen This PR or issue mainly concerns Tizen clients
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants