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