Skip to content

Commit

Permalink
Fix postMessage/onMessage handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy Vlasov committed Mar 17, 2020
1 parent d3d59d6 commit 25fe775
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/status_im/browser/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,10 @@
:browser/send-to-bridge
(fn [{:keys [message webview]}]
(when (and message webview)
(.injectJavaScript webview
(str "(function() {"
"window.ReactNativeWebView.onMessage(\""
(types/clj->json message)
"\")})")))))
(let [msg (str "ReactNativeWebView.onMessage('"
(types/clj->json message)
"');")]
(.injectJavaScript webview msg)))))

(re-frame/reg-fx
:browser/call-rpc
Expand Down
4 changes: 3 additions & 1 deletion src/status_im/ui/screens/browser/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@
(debounce/debounce-and-dispatch
[:browser/navigation-state-changed % error?]
500))
:on-message #(re-frame/dispatch [:browser/bridge-message-received %])
;; Extract event data here due to
;; https://reactjs.org/docs/events.html#event-pooling
:on-message #(re-frame/dispatch [:browser/bridge-message-received (.. % -nativeEvent -data)])
:on-load #(re-frame/dispatch [:browser/loading-started])
:on-error #(re-frame/dispatch [:browser/error-occured])
:injected-java-script-before-content-loaded (js-res/ethereum-provider (str network-id))
Expand Down

0 comments on commit 25fe775

Please sign in to comment.