upgrade react-native-webview-bridge (fix preloading of js on the first page, Android)

ensure that preloaded js in webview is executed only once
This commit is contained in:
Roman Volosovskyi 2017-02-22 16:54:32 +02:00
parent 125d1c8dff
commit 99931c24b9
4 changed files with 20 additions and 10 deletions

View File

@ -72,7 +72,7 @@
"react-native-tcp": "^2.0.4", "react-native-tcp": "^2.0.4",
"react-native-udp": "^1.2.6", "react-native-udp": "^1.2.6",
"react-native-vector-icons": "^2.0.3", "react-native-vector-icons": "^2.0.3",
"react-native-webview-bridge": "github:status-im/react-native-webview-bridge#0.33.6", "react-native-webview-bridge": "github:status-im/react-native-webview-bridge#0.33.7",
"readable-stream": "^1.0.33", "readable-stream": "^1.0.33",
"realm": "^0.14.3", "realm": "^0.14.3",
"status-dev-cli": "^1.1.3", "status-dev-cli": "^1.1.3",

View File

@ -1,3 +1,4 @@
if(typeof StatusHttpProvider === "undefined"){
var callbackId = 0; var callbackId = 0;
var callbacks = {}; var callbacks = {};
@ -103,9 +104,16 @@ StatusHttpProvider.prototype.isConnected = function () {
return false; return false;
} }
}; };
}
if (window.location.protocol == "https:") {
web3 = new Web3(new StatusHttpProvider("http://localhost:8545")); var protocol = window.location.protocol
} else { console.log(protocol);
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); if (typeof web3 === "undefined") {
if (protocol == "https:") {
console.log("StatusHttpProvider");
web3 = new Web3(new StatusHttpProvider("http://localhost:8545"));
} else if (protocol == "http:") {
console.log("HttpProvider");
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}
} }

View File

@ -139,7 +139,7 @@
:source {:uri url} :source {:uri url}
:render-error web-view-error :render-error web-view-error
:java-script-enabled true :java-script-enabled true
:injected-on-start-loading-java-script (str js-res/web3 js-res/web3-init) :injected-on-start-loading-java-script (str js-res/web3 js-res/jquery js-res/web3-init)
:injected-java-script (str js-res/webview-js extra-js) :injected-java-script (str js-res/webview-js extra-js)
:bounces false :bounces false
:on-navigation-state-change on-navigation-change :on-navigation-state-change on-navigation-change

View File

@ -11,9 +11,11 @@
(def dapp-js (str (slurp "resources/dapp.js"))) (def dapp-js (str (slurp "resources/dapp.js")))
(def webview-js (slurp "resources/webview.js")) (def webview-js (slurp "resources/webview.js"))
(def jquery (slurp "resources/jquery-3.1.1.min.js")) (def jquery (str
(def web3 (str jquery " if (typeof jQuery2 == 'undefined') {"
"; if (typeof Web3 == 'undefined') {" (slurp "resources/jquery-3.1.1.min.js")
"}"))
(def web3 (str "; if (typeof Web3 == 'undefined') {"
(slurp "resources/web3.0_16_0.min.js") (slurp "resources/web3.0_16_0.min.js")
"}")) "}"))
(def web3-init (slurp "resources/web3_init.js")) (def web3-init (slurp "resources/web3_init.js"))