mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
setTimeout bug fix
This commit is contained in:
parent
695b157e7b
commit
88a6b4edc7
@ -3,16 +3,18 @@ const resolver = require('./resolver.js');
|
|||||||
module.exports = function (provider) {
|
module.exports = function (provider) {
|
||||||
extension.webRequest.onBeforeRequest.addListener(details => {
|
extension.webRequest.onBeforeRequest.addListener(details => {
|
||||||
let name = details.url.substring(7, details.url.length - 1);
|
let name = details.url.substring(7, details.url.length - 1);
|
||||||
|
let clearTime = null;
|
||||||
extension.tabs.getSelected(null, tab => {
|
extension.tabs.getSelected(null, tab => {
|
||||||
extension.tabs.update(tab.id, { url: "loading.html" });
|
extension.tabs.update(tab.id, { url: "loading.html" });
|
||||||
|
|
||||||
setTimeout(() => {
|
clearTime = setTimeout(() => {
|
||||||
return extension.tabs.update(tab.id, { url: "404.html" });
|
return extension.tabs.update(tab.id, { url: "404.html" });
|
||||||
}, 60000);
|
}, 60000);
|
||||||
|
|
||||||
resolver.resolve(name, provider).then(ipfsHash => {
|
resolver.resolve(name, provider).then(ipfsHash => {
|
||||||
|
clearTimeout(clearTime);
|
||||||
let url = "https://gateway.ipfs.io/ipfs/" + ipfsHash;
|
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"
|
if (statusCode !== 200) return "Local"
|
||||||
extension.tabs.update(tab.id, { url: url })
|
extension.tabs.update(tab.id, { url: url })
|
||||||
})
|
})
|
||||||
@ -23,6 +25,7 @@ module.exports = function (provider) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
clearTimeout(clearTime);
|
||||||
let nameWithoutTld = name.substring(0, name.lastIndexOf('.'))
|
let nameWithoutTld = name.substring(0, name.lastIndexOf('.'))
|
||||||
let url = err === "no_mainnet" ? "no_mainnet" : "error"
|
let url = err === "no_mainnet" ? "no_mainnet" : "error"
|
||||||
extension.tabs.update(tab.id, {url: `${url}.html?name=${name}`})
|
extension.tabs.update(tab.id, {url: `${url}.html?name=${name}`})
|
||||||
|
Loading…
Reference in New Issue
Block a user