From 9175f2e1249e9cbe3e0402192efd038c75792ded Mon Sep 17 00:00:00 2001 From: Andrey Shovkoplyas Date: Mon, 24 Sep 2018 13:50:46 +0200 Subject: [PATCH] [#5698] null is not an object .sendToBridge Signed-off-by: Andrey Shovkoplyas --- resources/js/web3_init.js | 5 +---- resources/js/web3_opt_in.js | 5 +---- src/status_im/browser/core.cljs | 3 ++- src/status_im/ui/screens/browser/views.cljs | 6 ++---- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/resources/js/web3_init.js b/resources/js/web3_init.js index 9f465a24ed..7327e57f96 100644 --- a/resources/js/web3_init.js +++ b/resources/js/web3_init.js @@ -20,10 +20,7 @@ window.addEventListener('message', function (event) { WebViewBridge.onMessage = function (message) { data = JSON.parse(message); - if (data.type === "navigate-to-blank") - window.location.href = "about:blank"; - - else if (data.type === "status-api-success") + if (data.type === "status-api-success") { window.dispatchEvent(new CustomEvent('statusapi', { detail: { permissions: data.keys, data: data.data diff --git a/resources/js/web3_opt_in.js b/resources/js/web3_opt_in.js index c6466f96e8..841df8e4ff 100644 --- a/resources/js/web3_opt_in.js +++ b/resources/js/web3_opt_in.js @@ -21,10 +21,7 @@ window.addEventListener('message', function (event) { WebViewBridge.onMessage = function (message) { data = JSON.parse(message); - if (data.type === "navigate-to-blank") - window.location.href = "about:blank"; - - else if (data.type === "status-api-success") + if (data.type === "status-api-success") { if (data.keys == 'WEB3') { diff --git a/src/status_im/browser/core.cljs b/src/status_im/browser/core.cljs index 71e745402a..e5f9fa8e70 100644 --- a/src/status_im/browser/core.cljs +++ b/src/status_im/browser/core.cljs @@ -322,7 +322,8 @@ (re-frame/reg-fx :browser/send-to-bridge (fn [{:keys [message webview]}] - (.sendToBridge webview (types/clj->json message)))) + (when (and message webview) + (.sendToBridge webview (types/clj->json message))))) (re-frame/reg-fx :browser/call-rpc diff --git a/src/status_im/ui/screens/browser/views.cljs b/src/status_im/ui/screens/browser/views.cljs index 43fde357fa..364214eee7 100644 --- a/src/status_im/ui/screens/browser/views.cljs +++ b/src/status_im/ui/screens/browser/views.cljs @@ -48,12 +48,10 @@ [react/touchable-highlight {:style {:flex 1} :on-press #(re-frame/dispatch [:browser.ui/url-input-pressed])} [react/text {:style styles/url-text} (http/url-host url)]])]])) -(defn toolbar [webview error? url browser browser-id url-editing?] +(defn toolbar [error? url browser browser-id url-editing?] [toolbar.view/toolbar {} [toolbar.view/nav-button-with-count (actions/close (fn [] - (when @webview - (.sendToBridge @webview "navigate-to-blank")) (re-frame/dispatch [:navigate-back]) (when error? (re-frame/dispatch [:browser.ui/remove-browser-pressed browser-id]))))] @@ -108,7 +106,7 @@ (not (nil? (:url props)))))} [react/view styles/browser [status-bar/status-bar] - [toolbar webview error? url browser browser-id url-editing?] + [toolbar error? url browser browser-id url-editing?] [react/view components.styles/flex (if unsafe? [site-blocked.views/view {:can-go-back? can-go-back?