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-udp": "^1.2.6",
"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",
"realm": "^0.14.3",
"status-dev-cli": "^1.1.3",

View File

@ -1,3 +1,4 @@
if(typeof StatusHttpProvider === "undefined"){
var callbackId = 0;
var callbacks = {};
@ -103,9 +104,16 @@ StatusHttpProvider.prototype.isConnected = function () {
return false;
}
};
if (window.location.protocol == "https:") {
web3 = new Web3(new StatusHttpProvider("http://localhost:8545"));
} else {
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}
var protocol = window.location.protocol
console.log(protocol);
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}
:render-error web-view-error
: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)
:bounces false
:on-navigation-state-change on-navigation-change

View File

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