Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Refresh UI on nodeKind changes, e.g. personal -> public #5312

Merged
merged 13 commits into from
Apr 20, 2017
Merged

Conversation

jacogr
Copy link
Contributor

@jacogr jacogr commented Mar 28, 2017

Part of #5007

  • Poll parity_nodeKind
  • Adjust timing factor based on node type (long polls)
  • Refresh UI when kind availability/capability changes are detected (as we do with chain changes, e.g. node goes from public -> personal or full -> light)

@jacogr jacogr added A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. M7-ui labels Mar 28, 2017
@jacogr jacogr changed the title Adapt RPC calls & UI based on nodeKind Refresh UI on nodeKind changes, e.g. personal -> public Mar 29, 2017
@jacogr jacogr added A0-pleasereview 🤓 Pull request needs code review. and removed A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. labels Mar 30, 2017
Copy link
Contributor

@maciejhirsz maciejhirsz left a 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) {
Copy link
Contributor

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) {?

Copy link
Contributor Author

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.

@maciejhirsz maciejhirsz added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Apr 4, 2017
@jacogr jacogr added A0-pleasereview 🤓 Pull request needs code review. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Apr 19, 2017
Copy link
Contributor

@maciejhirsz maciejhirsz left a 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;
Copy link
Contributor

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).

Copy link
Contributor Author

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.

@maciejhirsz maciejhirsz added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Apr 20, 2017
@jacogr jacogr merged commit ba03ed4 into master Apr 20, 2017
@jacogr jacogr deleted the jg-node-kinds branch April 20, 2017 15:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants