8000 fix refresh page when request fail · etherscan-io/Ethplorer@677c370 · GitHub
[go: up one dir, main page]

Skip to content

Commit 677c370

Browse files
committed
fix refresh page when request fail
1 parent 70c60fb commit 677c370

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed

js/ethplorer.js

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -322,36 +322,43 @@ Ethplorer = {
322322
}
323323
var stopCheckingPendingAt = Date.now() + 1800000; // after 30 minutes
324324
function loadTxDetails(showResult = true) {
325-
$.getJSON(Ethplorer.service, requestData, function(_txHash){
326-
return function(data){
327-
if(data.debug){
328-
Ethplorer.requestDebug = data.debug;
325+
$.getJSON(Ethplorer.service, requestData)
326+
.done(function(_txHash){
327+
return function(data){
328+
if(data.debug){
329+
Ethplorer.requestDebug = data.debug;
330+
}
331+
if(data.ethPrice){
332+
Ethplorer.ethPrice = data.ethPrice;
333+
}
334+
if(showResult) {
335+
// if transaction is pending need send ga event
336+
if (data.pending) {
337+
Ethplorer.gaSendEvent('pageView', 'viewTx', 'tx-pending');
338+
}
339+
Ethplorer.showTxDetails(_txHash, data);
340+
} else if (!data.pending) {
341+
// Transaction not pending anymore. Reloading the view.
342+
location.reload();
343+
}
344+
// is transaction is pending
345+
if(data.pending && stopCheckingPendingAt > Date.now()){
346+
setTimeout(function() {
347+
loadTxDetails(false);
348+
}, 30000); // every 30 seconds
349+
}
329350
}
330351
if(data.ethPrice){
331352
Ethplorer.ethPrice = data.ethPrice;
332353
}
333-
if(showResult) {
334-
// if transaction is pending need send ga event
335-
if (data.pending) {
336-
Ethplorer.gaSendEvent('pageView', 'viewTx', 'tx-pending');
337-
}
338-
Ethplorer.showTxDetails(_txHash, data);
339-
} else if (!data.pending) {
340-
// Transaction not pending anymore. Reloading the view.
341-
location.reload();
342-
}
343-
// is transaction is pending
344-
if(data.pending && stopCheckingPendingAt > Date.now()){
345-
setTimeout(function() {
346-
loadTxDetails(false);
347-
}, 30000); // every 30 seconds
348-
}
349-
}
350-
if(data.ethPrice){
351-
Ethplorer.ethPrice = data.ethPrice;
352-
}
353-
Ethplorer.showTxDetails(_txHash, data);
354-
}(txHash));
354+
Ethplorer.showTxDetails(_txHash, data);
355+
}(txHash))
356+
.fail(function() {
357+
// Try send request again after 30 seconds
358+
setTimeout(function() {
359+
loadTxDetails(false);
360+
}, 30000);
361+
});
355362
}
356363
loadTxDetails();
357364
},

0 commit comments

Comments
 (0)
0