Navbar fixes #138
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
KittenSquad/glewlwyd!138
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "navbar-fix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The list of users in the two navigation bars (Admin and Profile) is not always synchronized with the actual list of users if two or more users are active. This PR fixes the issue.
The fix consists of two parts. First, only the currently active user is removed from
profileList[](I am avoidingslice()for this purpose because it is considered bad ReactJS practice on array-like states). Second,this.fetchAPI()is no longer called if a user has just logged out.An edge case producing a crash is also fixed by ensuring that
this.state.profileList[0]exist before attempting to index it.To test, please log in with at least two usernames, then log them out one by one, each time noticing the effects on the navigation bar dropdowns.
Hmm… the revision solves one problem by creating another (it breaks the green "Continue" button in certain scenarios).
Will revise and reopen. Closing for now.
I think this can be solved in another way, please see the code comments
@ -106,3 +104,1 @@if (!this.state.loggedIn) {this.fetchApi();}this.setState({loggedIn: message.loggedIn}, () => {you can try by changing the whole block like this:
@ -62,12 +62,8 @@ class App extends Component {this.setState({curNav: message.module, module: message.page});}} else if (message.type === 'loggedIn') {Like above, this block can be replaced by this:
@babelouest I found an other, more verbose solution meanwhile, but will now try your more compact suggestion and report back.
We can still make it more simple
@ -101,11 +101,8 @@ class App extends Component {} else if (message.type === 'profile') {this.fetchApi();This isn't required anymore, the
this.fetchApi();below will refresh the user list from the backend, and dispatch the new list to all the subcomponents@ -62,12 +62,8 @@ class App extends Component {this.setState({curNav: message.module, module: message.page});}} else if (message.type === 'loggedIn') {This isn't required anymore, the
this.fetchProfile();below will refresh the user list from the backend, and dispatch the new list to all the subcomponents@yrammos , when you push changes in a PR, please don't push force a rebased branch, simply add new commits on top of the last one, otherwise it's harder to follow up changes.
Also, when a required change is commited, you should use the
Resolve conversationbutton each time, likewise we'll know where we're at without having to re-read all the code changes.@babelouest, sorry about the rebase (symptom of a mostly solo worker).
I implemented your change but the issue with the Admin navbar persisted: the last user to log out would still appear on the navbar. I tracked it down to a tiny glitch with
this.fetchApi(). Kindly review for any edge cases I may have not considered.@yrammos , I've tested the PR and I've seen no edge case or new bugs. I'm pushing as is, thanks!