-
Notifications
You must be signed in to change notification settings - Fork 360
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
Fix storage config loading state not updated #7638
Fix storage config loading state not updated #7638
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Was waiting for this one :)
@eladlachmi my understanding of the root cause is different, let me know what I missed. AFAIU when the user isn't logged in the storage-provider is still being called and returns 401, hence not setting it. Once the user is logged in, the storage-provider isn't being called again therefore it is stuck in a loading state. I don't see how this change fixes the problem during logins. |
@itaiad200 You're right. Those are two separate issues that manifest with the same symptoms. On it... |
The issue has 2 root causes? That's rare. How was this tested? I believe the issue isn't resolved by these fixes |
@itaiad200
This was tested manually and by the E2E tests that are part of this PR.
Maybe... How was this belief tested? |
I experimented with this issue before. I alo checked out this branch and was able to reproduce the issue. I might have configured something wrong, but from my previous tries, the StorageProvider needs to be called again after a successful login. I don't know React well enough to understand the deps/context handling and if it happens in this fix. |
Yeah, that's exactly what this change does |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your patience throughout this PR.
* Fix storage config loading state not updated * E2E test coverage for fix * useEffect hook missing dep on logged in user * E2E test coverage for logout/login scenario
Closes #7249
Change Description
Background
Please refer to the linked issue for a full description of the bug.
Root Cause and Solution
There are actually two issues here, which manifest in the same way:
1.
loading
property not updatedThe object viewer initially renders in a loading state. The
useStorageConfig
context hook re-renders the component when the storage config is loaded (from server or memory). During it's render, the component checksconfig.loading
. In the initial state of the context,loading
is set totrue
. However, when setting the state received from the server, theloading
property isn't set, so the component re-renders into the same loading state.To fix this issue we spread the server response object and add a
loading
property with a valuefalse
. Onceconfig.loading
is set to false, the object viewer component re-renders correctly.2. The
useEffect
hook in the storage config context was missing a dep on the logged in userWhen there is no logged in user,
fetchStorageConfig
rejects with HTTP status 401. Since there was a missing dependency, theuseEffect
hook would never trigger a re-render of the context value and thus not trigger a re-render of components that use it. Adding theuser
from theuseUser
hook to the dependencies array triggers the chain of re-renders as expected.