fix qr code decoding and remove extra data
Former-commit-id: 755e9bf2b3
This commit is contained in:
parent
d094cd286c
commit
4870fef74b
|
@ -67,7 +67,7 @@
|
|||
phone-number [:get :phone-number]
|
||||
email [:get :email]
|
||||
status [:get :status]
|
||||
identity [:get :identity]]
|
||||
identity [:get-in [:user-identity :public]]]
|
||||
[view {:style st/profile}
|
||||
[touchable-highlight {:style st/back-btn-touchable
|
||||
:on-press #(dispatch [:navigate-back])}
|
||||
|
@ -93,7 +93,5 @@
|
|||
:value email}]
|
||||
[view st/qr-code-container
|
||||
[qr-code {:value (clj->json {:name username
|
||||
:phone-number phone-number
|
||||
:address email
|
||||
:whisper-identity identity})
|
||||
:size 150}]]]])
|
||||
:size 200}]]]])
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
[status-im.components.styles :refer [color-blue]]
|
||||
[status-im.i18n :refer [label]]
|
||||
[status-im.qr-scanner.styles :as st]
|
||||
[status-im.utils.types :refer [json->clj]]
|
||||
[status-im.utils.logging :as log]))
|
||||
|
||||
(defn qr-scanner-toolbar []
|
||||
|
@ -23,12 +24,13 @@
|
|||
[]
|
||||
[view st/barcode-scanner-container
|
||||
[qr-scanner-toolbar]
|
||||
[camera {:onBarCodeRead (fn [{:keys [name address whisper-identity phone-number] :as contact}]
|
||||
[camera {:onBarCodeRead (fn [data]
|
||||
(let [{:keys [name address whisper-identity phone-number] :as contact} (json->clj (.-data data))]
|
||||
(when name (dispatch [:set-in [:new-contact :name] name]))
|
||||
(when address (dispatch [:set-in [:new-contact :address] address]))
|
||||
(when whisper-identity (dispatch [:set-in [:new-contact :whisper-identity] whisper-identity]))
|
||||
(when phone-number (dispatch [:set-in [:new-contact :phone-number] phone-number]))
|
||||
(dispatch [:navigate-back]))
|
||||
(dispatch [:navigate-back])))
|
||||
:style st/barcode-scanner}]
|
||||
[view st/rectangle-container
|
||||
[view st/rectangle
|
||||
|
|
|
@ -8,5 +8,8 @@
|
|||
(defn to-edn-string [value]
|
||||
(with-out-str (pr value)))
|
||||
|
||||
(defn clj->json [ds]
|
||||
(.stringify js/JSON (clj->js ds)))
|
||||
(defn clj->json [data]
|
||||
(.stringify js/JSON (clj->js data)))
|
||||
|
||||
(defn json->clj [data]
|
||||
(js->clj (.parse js/JSON data)))
|
Loading…
Reference in New Issue