[#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]] (fn [cofx [_ network]]
(network/save-non-rpc-network 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 (handlers/register-handler-fx
:network.ui/remove-network-confirmed :network.ui/remove-network-confirmed
(fn [cofx [_ network]] (fn [cofx [_ network]]

View File

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

View File

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