Closed Glubs9 closed 2 years ago
Looks like if the IP address is correct when you load the page, and you hit backspace, it stays as "Connected". I think this is a re-rendering issue - the safety panel doesn't know to re-render when the socket status changes because the socket status isn't part of any state or props.
I think the way to fix this is instead of using that.socket
we should pass a status={this.socket.readyState}
prop to the safety panel. In fact, that
feels dirty to me already, I think we should have a prop for each property of that
we use instead - could you do this in a small second commit?
Also, I think what we want to display is simply "Connected" (ready state 1) or "Disconnected" (any other ready state). We've got reconnection logic that should make the "Closed" and "Closing" states very transient, and "Connecting" and "Connected" look very similar visually.
I don't think it is wise to change that to be a prop. I did misuse it in the original commit but looking at the only place it is used (line 67-69) it seems to be appropriate. Making use of the object to make it clear how it influences state, rather than passing arbitrary callbacks.
It is you're call though.
You can leave that
there if you like for the existing use case. The current use in 67-69 is harmless, but the reason I suggested removing it is that it can be used in a dangerous way, so removing it makes it harder to accidentally do something dangerous. For instance:
that.propertyOutsideOfState
again in the render function, which will cause the same bug as we've just seen hereAlso, looks like you've forgotten to edit / push the change where you give the <SafetyPanel />
a sockStatus
prop!
setState({ sockStatus: ... })
when the socket state changes?@Glubs9 I've just pushed some edits (fixing the issue I mentioned above with re-renders not being triggered, eg if you deleted a single character of the IP it wouldn't say "Disconnected")
Merging now
gosh i'm really sorry. I had the fix written I just forgot to push it. I've been busy moving, I very much apologize
All good, take it easy!
4 is the issue this pull request tries to solve