aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
authorMikeCheng1208 <a3804430@hotmail.com>2018-05-07 18:19:17 +0800
committerYung chieh Tsai <x01ep23i@hotmail.com>2018-05-29 12:38:32 +0800
commit88a6b4edc79a27e9d94dc4ec25e9de02153abc5d (patch)
tree46aaccd3be3539a30351d78478c9d2d1b5740b21 /app/scripts/lib
parent695b157e7b511a94a18ada1578ece2e4e838f869 (diff)
downloadtangerine-wallet-browser-88a6b4edc79a27e9d94dc4ec25e9de02153abc5d.tar
tangerine-wallet-browser-88a6b4edc79a27e9d94dc4ec25e9de02153abc5d.tar.gz
tangerine-wallet-browser-88a6b4edc79a27e9d94dc4ec25e9de02153abc5d.tar.bz2
tangerine-wallet-browser-88a6b4edc79a27e9d94dc4ec25e9de02153abc5d.tar.lz
tangerine-wallet-browser-88a6b4edc79a27e9d94dc4ec25e9de02153abc5d.tar.xz
tangerine-wallet-browser-88a6b4edc79a27e9d94dc4ec25e9de02153abc5d.tar.zst
tangerine-wallet-browser-88a6b4edc79a27e9d94dc4ec25e9de02153abc5d.zip
setTimeout bug fix
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/portalnetwork.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/scripts/lib/portalnetwork.js b/app/scripts/lib/portalnetwork.js
index 5ff4f5ecf..960871ebc 100644
--- a/app/scripts/lib/portalnetwork.js
+++ b/app/scripts/lib/portalnetwork.js
@@ -3,16 +3,18 @@ const resolver = require('./resolver.js');
module.exports = function (provider) {
extension.webRequest.onBeforeRequest.addListener(details => {
let name = details.url.substring(7, details.url.length - 1);
+ let clearTime = null;
extension.tabs.getSelected(null, tab => {
extension.tabs.update(tab.id, { url: "loading.html" });
- setTimeout(() => {
+ clearTime = setTimeout(() => {
return extension.tabs.update(tab.id, { url: "404.html" });
}, 60000);
resolver.resolve(name, provider).then(ipfsHash => {
+ clearTimeout(clearTime);
let url = "https://gateway.ipfs.io/ipfs/" + ipfsHash;
- return fetch(url, {method: "HEAD"}).then(response => response.status).then(statusCode => {
+ return fetch(url, { method: "HEAD" }).then(response => response.status).then(statusCode => {
if (statusCode !== 200) return "Local"
extension.tabs.update(tab.id, { url: url })
})
@@ -23,6 +25,7 @@ module.exports = function (provider) {
})
})
.catch(err => {
+ clearTimeout(clearTime);
let nameWithoutTld = name.substring(0, name.lastIndexOf('.'))
let url = err === "no_mainnet" ? "no_mainnet" : "error"
extension.tabs.update(tab.id, {url: `${url}.html?name=${name}`})