Improve error message when status-go throw an error
This commit is contained in:
parent
2abdd61f30
commit
dd6d679322
|
@ -14,6 +14,8 @@
|
||||||
:type-a-message "Type a message..."
|
:type-a-message "Type a message..."
|
||||||
:type-a-command "Start typing a command..."
|
:type-a-command "Start typing a command..."
|
||||||
:error "Error"
|
:error "Error"
|
||||||
|
:unknown-status-go-error "Unknown status-go error"
|
||||||
|
:node-unavailable "No ethereum node running"
|
||||||
|
|
||||||
:camera-access-error "To grant the required camera permission, please, go to your system settings and make sure that Status > Camera is selected."
|
:camera-access-error "To grant the required camera permission, please, go to your system settings and make sure that Status > Camera is selected."
|
||||||
:photos-access-error "To grant the required photos permission, please, go to your system settings and make sure that Status > Photos is selected."
|
:photos-access-error "To grant the required photos permission, please, go to your system settings and make sure that Status > Photos is selected."
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
(ns status-im.ui.screens.accounts.login.views
|
(ns status-im.ui.screens.accounts.login.views
|
||||||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
||||||
(:require [re-frame.core :refer [dispatch dispatch-sync]]
|
(:require [clojure.string :as string]
|
||||||
|
[re-frame.core :refer [dispatch dispatch-sync]]
|
||||||
[status-im.ui.screens.accounts.styles :as ast]
|
[status-im.ui.screens.accounts.styles :as ast]
|
||||||
[status-im.ui.screens.accounts.views :refer [account-badge]]
|
[status-im.ui.screens.accounts.views :refer [account-badge]]
|
||||||
[status-im.components.text-input-with-label.view :refer [text-input-with-label]]
|
[status-im.components.text-input-with-label.view :refer [text-input-with-label]]
|
||||||
|
@ -27,6 +28,19 @@
|
||||||
(.blur @password-text-input)
|
(.blur @password-text-input)
|
||||||
(dispatch [:login-account address password]))
|
(dispatch [:login-account address password]))
|
||||||
|
|
||||||
|
(defn- error-key [error]
|
||||||
|
;; TODO Improved selection logic when status-go provide an error code
|
||||||
|
;; see https://github.com/status-im/status-go/issues/278
|
||||||
|
(cond
|
||||||
|
(string/starts-with? error "there is no running node")
|
||||||
|
:t/node-unavailable
|
||||||
|
|
||||||
|
(string/starts-with? error "cannot retrieve a valid key")
|
||||||
|
:t/wrong-password
|
||||||
|
|
||||||
|
:else
|
||||||
|
:t/unknown-status-go-error))
|
||||||
|
|
||||||
(defview login []
|
(defview login []
|
||||||
(letsubs [{:keys [address photo-path name password error processing]} [:get :accounts/login]]
|
(letsubs [{:keys [address photo-path name password error processing]} [:get :accounts/login]]
|
||||||
[view ast/accounts-container
|
[view ast/accounts-container
|
||||||
|
@ -46,7 +60,7 @@
|
||||||
:on-submit-editing #(login-account password-text-input address password)
|
:on-submit-editing #(login-account password-text-input address password)
|
||||||
:auto-focus true
|
:auto-focus true
|
||||||
:secure-text-entry true
|
:secure-text-entry true
|
||||||
:error (when (pos? (count error)) (i18n/label :t/wrong-password))}]]
|
:error (when (pos? (count error)) (i18n/label (error-key error)))}]]
|
||||||
[view {:margin-top 16}
|
[view {:margin-top 16}
|
||||||
[touchable-highlight {:on-press #(login-account password-text-input address password)}
|
[touchable-highlight {:on-press #(login-account password-text-input address password)}
|
||||||
[view st/sign-in-button
|
[view st/sign-in-button
|
||||||
|
|
Loading…
Reference in New Issue