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

Find a prettier fix for loading pages before getting actor #110

Closed
joepio opened this issue Nov 14, 2021 · 1 comment
Closed

Find a prettier fix for loading pages before getting actor #110

joepio opened this issue Nov 14, 2021 · 1 comment

Comments

@joepio
Copy link
Member

joepio commented Nov 14, 2021

I'm working on authentication #108 and noticed an annoyance. When I refresh the page, the first request will be sent as PublicAgent (no agent), and will therefore return a 401 if the resource requires signing in. However, the user will be signed in automatically a fraction later. This would result in the user being signed in, yet staring at an unauthorized page. He could press the retry button, of course, but that's suboptimal...

So I added some logic in the useResource hook, which keeps track of the current agent. If the agent changes, re-try fetching the resource. It works pretty well, but it adds quite a bit of logic, and possibly makes performance worse.

I'd like to find a better solution to this.

@joepio
Copy link
Member Author

joepio commented Nov 19, 2021

I currently went for re-fetching all unauthorized resources in the store when setAgent() is called with some Agent.

@joepio joepio closed this as completed Nov 19, 2021
joepio added a commit that referenced this issue Nov 21, 2021
joepio added a commit that referenced this issue Nov 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant