-
Notifications
You must be signed in to change notification settings - Fork 22
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
(15) refactor: network settings actions #360
Conversation
05d28ca
to
9e2c5c0
Compare
6e85529
to
9f954f2
Compare
- This action replaces the NETWORK_UPDATE_ERRORS
- Improve readability
- change network settings status to `WAITING` just after persist the custom network settings - throw a fatal exception message to the user if the wallet is not found - stop the wallet and clean its storage and addresses - add a reducer for RELOAD_WALLET_REQUESTED action to clean the tokens history and balance on redux store
9f954f2
to
4558d11
Compare
4558d11
to
02acec2
Compare
- The full check will happen when the custom network contain a valid URL for wallet-service. This behavior is to avoid a bypass on the network status bar when the wallet-service is given. This is important because the wallet-service has precedence over fullnode.
const networkSettings = useSelector((state) => state.networkSettings); | ||
if (eq(networkSettings, PRE_SETTINGS_MAINNET)) { | ||
return null; | ||
function notMainnet(networkSettings) { |
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 this method deserves a comment explaining why you split the validation in two.
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.
Added: f31c263
src/sagas/networkSettings.js
Outdated
if (status === NETWORKSETTINGS_STATUS.WAITING) { | ||
yield put(networkSettingsUpdateSuccess()); | ||
} else { | ||
yield put(networkSettingsUpdateReady()); |
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 believe this deserves a comment explaining these state changes and why they happen here
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.
Added: 3825b2e
src/actions.js
Outdated
@@ -120,11 +120,22 @@ export const types = { | |||
// NOTE: These actions follows a taxonomy that should be applied | |||
// to all other actions. | |||
// See: https://github.com/HathorNetwork/hathor-wallet-mobile/issues/334 | |||
NETWORKSETTINGS_UPDATE: 'NETWORK_SETTINGS_UPDATE', | |||
/* It delivers the user's network settings input from the form. */ |
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.
/* It delivers the user's network settings input from the form. */ | |
/* It initiates an update of the network settings based on user input from a form. */ |
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.
Resolved: d994fdb
src/actions.js
Outdated
NETWORKSETTINGS_PERSIST_STORE: 'NETWORKSETTINGS_PERSIST_STORE', | ||
/* It indicates the persistence is complete and the wallet will be reloaded. */ | ||
NETWORKSETTINGS_UPDATE_WAITING: 'NETWORKSETTINGS_UPDATE_WAITING', | ||
/* It indicates the update is complete after wallet reloads. */ |
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.
/* It indicates the update is complete after wallet reloads. */ | |
/* It indicates the update is complete after the wallet reloads. */ |
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.
Resolved: d994fdb
src/actions.js
Outdated
* Emits the waiting signal after persist the custom network. | ||
* It means the wallet will reload. |
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.
* Emits the waiting signal after persist the custom network. | |
* It means the wallet will reload. | |
* Action indicating that the network settings update process is in a waiting state. | |
* This is used after persisting custom network configurations, resulting in a wallet reload. |
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.
Resolved: d994fdb
src/actions.js
Outdated
* Emits the success signal after wallet reloads. | ||
* It servers as hook for the frontend to provide feedback for the user. |
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.
* Emits the success signal after wallet reloads. | |
* It servers as hook for the frontend to provide feedback for the user. | |
* Action indicating that the network settings update was successful | |
* This serves as a hook for the frontend to provide feedback to the user. |
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.
The idea here (and in the previous comments) is that the action by itself does not emit anything, somewhere else is dispatching this action
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.
Resolved: d994fdb
src/actions.js
Outdated
* Emits invalid signal for custom network settings request inputs. | ||
* It means the form should present the invalid message on the corresponding inputs. |
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.
* Emits invalid signal for custom network settings request inputs. | |
* It means the form should present the invalid message on the corresponding inputs. | |
* Action indicating an invalid state for the custom network settings request inputs. | |
* Intended to trigger the presentation of invalid messages on the corresponding form inputs. |
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.
Resolved: d994fdb
This PR aims to improve the Network Settings Actions by decomposing it in actions that conveys a better semantic.
Acceptance Criteria
Warning
The following video has a legacy behavior when showing the network status bar alert for mainnet settings when removing only the wallet service URLs fields. This bar should show up only if the required fields diverges from the what is set to be the mainnet. You find the video with the correct behavior after this one.
ds-action-refactoring-clip.mp4
Correct behavior regarding network status bar:
ds-action-refactoring-rv1-clip.mp4
Closes: #358
Security Checklist