[#10011] Listen to nfc state changes

This commit is contained in:
Roman Volosovskyi 2020-03-05 15:20:16 +02:00
parent c4a7849c9d
commit 4f95e0bcf4
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
5 changed files with 18 additions and 12 deletions

View File

@ -38,7 +38,7 @@
"react-native-screens": "^1.0.0-alpha.23",
"react-native-shake": "^3.3.1",
"react-native-splash-screen": "^3.2.0",
"react-native-status-keycard": "git+https://github.com/status-im/react-native-status-keycard.git#v2.5.19",
"react-native-status-keycard": "git+https://github.com/status-im/react-native-status-keycard.git#v2.5.20",
"react-native-svg": "^9.8.4",
"react-native-touch-id": "^4.4.1",
"react-native-webview": "^6.11.1",

View File

@ -4900,9 +4900,9 @@ react-native-splash-screen@^3.2.0:
resolved "https://registry.yarnpkg.com/react-native-splash-screen/-/react-native-splash-screen-3.2.0.tgz#d47ec8557b1ba988ee3ea98d01463081b60fff45"
integrity sha512-Ls9qiNZzW/OLFoI25wfjjAcrf2DZ975hn2vr6U9gyuxi2nooVbzQeFoQS5vQcbCt9QX5NY8ASEEAtlLdIa6KVg==
"react-native-status-keycard@git+https://github.com/status-im/react-native-status-keycard.git#v2.5.19":
"react-native-status-keycard@git+https://github.com/status-im/react-native-status-keycard.git#v2.5.20":
version "2.5.17"
resolved "git+https://github.com/status-im/react-native-status-keycard.git#8fb12850d72918d3e89e4fcfc8fa699c2ce3f203"
resolved "git+https://github.com/status-im/react-native-status-keycard.git#38ca8597e26472f0d257467652544df084de6345"
react-native-svg@^9.8.4:
version "9.11.1"

View File

@ -51,12 +51,24 @@
platform/android?)
(.addListener event-emitter "keyCardOnDisconnected" callback)))
(defn on-nfc-enabled [callback]
(when (and config/hardwallet-enabled?
platform/android?)
(.addListener event-emitter "keyCardOnNFCEnabled" callback)))
(defn on-nfc-disabled [callback]
(when (and config/hardwallet-enabled?
platform/android?)
(.addListener event-emitter "keyCardOnNFCDisabled" callback)))
(defn register-card-events []
(doseq [listener @active-listeners]
(remove-event-listener listener))
(reset! active-listeners
[(on-card-connected #(re-frame/dispatch [:hardwallet.callback/on-card-connected]))
(on-card-disconnected #(re-frame/dispatch [:hardwallet.callback/on-card-disconnected]))]))
(on-card-disconnected #(re-frame/dispatch [:hardwallet.callback/on-card-disconnected]))
(on-nfc-enabled #(re-frame/dispatch [:hardwallet.callback/check-nfc-enabled-success true]))
(on-nfc-disabled #(re-frame/dispatch [:hardwallet.callback/check-nfc-enabled-success false]))]))
(defn get-application-info [{:keys [pairing on-success]}]
(log/debug "[keycard] get-application-info")

View File

@ -119,15 +119,10 @@
(fx/defn on-check-nfc-enabled-success
{:events [:hardwallet.callback/check-nfc-enabled-success]}
[{:keys [db]} nfc-enabled?]
(log/debug "[hardwallet] check-nfc-enabled-success"
"nfc-enabled?" nfc-enabled?)
{:db (assoc-in db [:hardwallet :nfc-enabled?] nfc-enabled?)})
(fx/defn return-back-from-nfc-settings [{:keys [db]}]
(when (or (get-in db [:hardwallet :flow])
(get-in db [:hardwallet :pin :enter-step])
(get-in db [:hardwallet :on-card-connected])
(get-in db [:hardwallet :on-card-read]))
{:hardwallet/check-nfc-enabled nil}))
(defn- proceed-to-pin-confirmation [fx]
(assoc-in fx [:db :hardwallet :pin :enter-step] :confirmation))

View File

@ -150,7 +150,6 @@
(dissoc :app-in-background-since)
(assoc :app-active-since now))}
(mailserver/process-next-messages-request)
(hardwallet/return-back-from-nfc-settings)
#(when requires-bio-auth
(biometric/authenticate % on-biometric-auth-result authentication-options)))))