-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Refresh UI on nodeKind changes, e.g. personal -> public #5312
Conversation
# Conflicts: # js/src/redux/providers/status.js # js/src/redux/providers/statusReducer.js
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.
I think it would be most readable if the conditions for the reload were split in separate variables (or functions even), e.g.:
const hasChainChanged = /* ... */;
const hasNodeAvailabilityChanged = /* ... */;
const hasNodeCapacityChanged = /* ... */;
if (hasChainChanged || hasNodeAvailabilityChanged || hasNodeCapacityChanged ) {
/* force reload */
}
+/- my pedantic Java-esque variable naming :p
let forceReload = newChain !== netChain && netChain !== DEFAULT_NETCHAIN; | ||
|
||
// force reload when nodeKind (availability/capability) has changed | ||
if (!forceReload && collection.nodeKind !== null && nodeKind !== null) { |
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.
Shouldn't nodeKind
checks be outside of the if (newChain) {
?
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.
Will double-check, thanks. Think you are correct though.
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.
Looks good, left one comment but that's more for my information than anything.
const hasChainChanged = newChain !== netChain; | ||
const isInitialChain = netChain === DEFAULT_NETCHAIN; | ||
|
||
reloadChain = !isInitialChain && hasChainChanged; |
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.
I don't really follow why a reload does not happen if current chain is a default chain? (I know the logic here didn't change, just curious).
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.
Maybe it is slightly wrongly named. On startup we don't know the chain, so we set it to DEFAULT_CHAIN
(DEFAULT_CHAIN = '(unknown)'
). So when the value changes from this, we don't do the reload, but on any subsequent changes, we do.
Part of #5007