diff options
author | kumavis <kumavis@users.noreply.github.com> | 2017-01-22 02:06:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-22 02:06:50 +0800 |
commit | 74dc20bdf179cbd8b25f6fae007553784466e3ff (patch) | |
tree | 4b28d3230bf38c68b68e40efcb5b1bf810eacf3e /ui/app/actions.js | |
parent | bc1615f032186e88aebfa9dac38039dcff263162 (diff) | |
parent | 247f7aad5e358fae33616fd310e695e06673dd19 (diff) | |
download | tangerine-wallet-browser-74dc20bdf179cbd8b25f6fae007553784466e3ff.tar tangerine-wallet-browser-74dc20bdf179cbd8b25f6fae007553784466e3ff.tar.gz tangerine-wallet-browser-74dc20bdf179cbd8b25f6fae007553784466e3ff.tar.bz2 tangerine-wallet-browser-74dc20bdf179cbd8b25f6fae007553784466e3ff.tar.lz tangerine-wallet-browser-74dc20bdf179cbd8b25f6fae007553784466e3ff.tar.xz tangerine-wallet-browser-74dc20bdf179cbd8b25f6fae007553784466e3ff.tar.zst tangerine-wallet-browser-74dc20bdf179cbd8b25f6fae007553784466e3ff.zip |
Merge branch 'dev' into obs-store2
Diffstat (limited to 'ui/app/actions.js')
-rw-r--r-- | ui/app/actions.js | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js index 5a3968f82..bf3617310 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -32,16 +32,21 @@ var actions = { SHOW_INIT_MENU: 'SHOW_INIT_MENU', SHOW_NEW_VAULT_SEED: 'SHOW_NEW_VAULT_SEED', SHOW_INFO_PAGE: 'SHOW_INFO_PAGE', + SHOW_IMPORT_PAGE: 'SHOW_IMPORT_PAGE', unlockMetamask: unlockMetamask, unlockFailed: unlockFailed, showCreateVault: showCreateVault, showRestoreVault: showRestoreVault, showInitializeMenu: showInitializeMenu, + showImportPage, createNewVaultAndKeychain: createNewVaultAndKeychain, createNewVaultAndRestore: createNewVaultAndRestore, createNewVaultInProgress: createNewVaultInProgress, addNewKeyring, + importNewAccount, addNewAccount, + NEW_ACCOUNT_SCREEN: 'NEW_ACCOUNT_SCREEN', + navigateToNewAccountScreen, showNewVaultSeed: showNewVaultSeed, showInfoPage: showInfoPage, // seed recovery actions @@ -249,7 +254,36 @@ function requestRevealSeed (password) { } function addNewKeyring (type, opts) { - return callBackgroundThenUpdate(background.addNewKeyring, type, opts) + return (dispatch) => { + dispatch(actions.showLoadingIndication()) + background.addNewKeyring(type, opts, (err, newState) => { + dispatch(actions.hideLoadingIndication()) + if (err) return dispatch(actions.displayWarning(err.message)) + dispatch(actions.updateMetamaskState(newState)) + dispatch(actions.showAccountsPage()) + }) + } +} + +function importNewAccount (strategy, args) { + return (dispatch) => { + dispatch(actions.showLoadingIndication('This may take a while, be patient.')) + background.importAccountWithStrategy(strategy, args, (err, newState) => { + dispatch(actions.hideLoadingIndication()) + if (err) return dispatch(actions.displayWarning(err.message)) + dispatch(actions.updateMetamaskState(newState)) + dispatch({ + type: actions.SHOW_ACCOUNT_DETAIL, + value: newState.selectedAccount, + }) + }) + } +} + +function navigateToNewAccountScreen() { + return { + type: this.NEW_ACCOUNT_SCREEN, + } } function addNewAccount (ringNumber = 0) { @@ -376,6 +410,12 @@ function showInitializeMenu () { } } +function showImportPage () { + return { + type: actions.SHOW_IMPORT_PAGE, + } +} + function agreeToDisclaimer () { return (dispatch) => { dispatch(this.showLoadingIndication()) @@ -590,9 +630,10 @@ function useEtherscanProvider () { } } -function showLoadingIndication () { +function showLoadingIndication (message) { return { type: actions.SHOW_LOADING, + value: message, } } |