[#7681] Show confirmation dialog on switching to network with upstream RPC

This commit is contained in:
Roman Volosovskyi 2019-03-21 16:39:37 +02:00
parent 4150fbfe77
commit 65e7e06b27
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
3 changed files with 35 additions and 16 deletions

View File

@ -498,6 +498,11 @@
(fn [cofx [_ network]]
(network/save-non-rpc-network cofx network)))
(handlers/register-handler-fx
:network.ui/save-rpc-network-pressed
(fn [cofx [_ network]]
(network/save-rpc-network cofx network)))
(handlers/register-handler-fx
:network.ui/remove-network-confirmed
(fn [cofx [_ network]]

View File

@ -108,22 +108,27 @@
{:db (assoc db :networks/manage (validate-manage default-manage))
:dispatch [:navigate-to :edit-network]})
(fx/defn connect-success [{:keys [db now] :as cofx} {:keys [network-id on-success client-version]}]
(let [current-network (get-in db [:account/account :networks (:network db)])]
(if (ethereum/network-with-upstream-rpc? current-network)
(fx/merge cofx
#(action-handler on-success {:network-id network-id :client-version client-version} %)
(accounts.update/account-update
{:network network-id
:last-updated now}
{:success-event [:accounts.update.callback/save-settings-success]}))
(fx/merge cofx
{:ui/show-confirmation {:title (i18n/label :t/close-app-title)
:content (i18n/label :t/close-app-content)
(fx/defn connect-success [{:keys [db] :as cofx}
{:keys [network-id on-success client-version]}]
(let [current-network (get-in db [:account/account :networks (:network db)])
network-with-upstream-rpc? (ethereum/network-with-upstream-rpc?
current-network)]
(fx/merge
cofx
{:ui/show-confirmation
{:title (i18n/label :t/close-app-title)
:content (if network-with-upstream-rpc?
(i18n/label :t/logout-app-content)
(i18n/label :t/close-app-content))
:confirm-button-text (i18n/label :t/close-app-button)
:on-accept #(re-frame/dispatch [:network.ui/save-non-rpc-network-pressed network-id])
:on-accept #(re-frame/dispatch
[(if network-with-upstream-rpc?
:network.ui/save-rpc-network-pressed
:network.ui/save-non-rpc-network-pressed)
network-id])
:on-cancel nil}}
#(action-handler on-success {:network-id network-id :client-version client-version} %)))))
#(action-handler on-success {:network-id network-id
:client-version client-version} %))))
(defn connect-failure [{:keys [network-id on-failure reason]}]
(action-handler on-failure
@ -193,6 +198,14 @@
:last-updated now}
{:success-event [:network.callback/non-rpc-network-saved]}))
(fx/defn save-rpc-network
[{:keys [now] :as cofx} network]
(accounts.update/account-update
cofx
{:network network
:last-updated now}
{:success-event [:accounts.update.callback/save-settings-success]}))
(fx/defn remove-network
[{:keys [db now] :as cofx} network]
(let [networks (dissoc (get-in db [:account/account :networks]) network)]

View File

@ -640,6 +640,7 @@
"soon": "Soon",
"wallet-asset": "Asset",
"close-app-content": "The app will stop and close. When you reopen it, the selected network will be used",
"logout-app-content": "The account will be logged out. When you log in again, the selected network will be used",
"password-description": "You'll need this password to open the app and confirm transactions.",
"currency-display-name-afn": "Afghanistan Afghani",
"word-n-description": "In order to check if you have backed up your recovery phrase correctly, enter the word #{{number}} above.",