Fixes #4223: No error when scanning incorrect public key QR code

Signed-off-by: Pedro Pombeiro <pombeirp@users.noreply.github.com>
This commit is contained in:
pacamara 2018-05-28 18:37:11 +01:00 committed by Pedro Pombeiro
parent 535ae6b481
commit 45c645082e
No known key found for this signature in database
GPG Key ID: A65DEB11E4BBC647
2 changed files with 9 additions and 5 deletions

View File

@ -342,7 +342,8 @@
:name "Name"
:specify-name "Specify a name"
:address-explication "Your public key is used to generate your address on Ethereum and is a series of numbers and letters. You can find it easily in your profile"
:use-valid-contact-code "Please enter a valid contact code"
:unable-to-read-this-code "Unable to read this code"
:use-valid-contact-code "Please scan a valid contact code"
:enter-valid-public-key "Please enter a valid public key or scan a QR code"
:contact-already-added "The contact has already been added"
:can-not-add-yourself "You can't add yourself"

View File

@ -1,5 +1,6 @@
(ns status-im.ui.screens.contacts.events
(:require [re-frame.core :as re-frame]
[status-im.i18n :as i18n]
[status-im.chat.events :as chat.events]
[status-im.data-store.contacts :as contacts-store]
[status-im.transport.message.core :as transport]
@ -10,7 +11,8 @@
[status-im.utils.contacts :as utils.contacts]
[status-im.utils.handlers :as handlers]
[status-im.utils.handlers-macro :as handlers-macro]
[status-im.utils.js-resources :as js-res]))
[status-im.utils.js-resources :as js-res]
[status-im.utils.utils :as utils]))
(re-frame/reg-cofx
:get-default-contacts
@ -89,9 +91,10 @@
[(re-frame/inject-cofx :random-id)]
(fn [{:keys [db] :as cofx} [_ _ contact-identity]]
(let [current-account (:account/account db)
fx {:db (assoc db :contacts/new-identity contact-identity)}]
(if (new-chat.db/validate-pub-key contact-identity current-account)
fx
fx {:db (assoc db :contacts/new-identity contact-identity)}
validation-result (new-chat.db/validate-pub-key contact-identity current-account)]
(if (some? validation-result)
(utils/show-popup (i18n/label :t/unable-to-read-this-code) validation-result #(re-frame/dispatch [:navigate-to-clean :home]))
(handlers-macro/merge-fx cofx
fx
(add-contact-and-open-chat contact-identity))))))