1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Remove usage of setInterval (#4481)

* Migrate from setInterval to setTimeout, fixes #4480

* Add fail case
This commit is contained in:
Mike Perham 2020-03-15 13:32:10 -07:00 committed by GitHub
parent 813cb7093c
commit 2ac87ba839
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,7 +19,8 @@ Sidekiq = {};
$(function() {
var pollpath = $('body').data('poll-path');
if (pollpath != "") {
updatePage(pollpath);
var ti = parseInt(localStorage.timeInterval) || 2000;
setTimeout(function(){updatePage(pollpath)}, ti);
}
$(document).on('click', '.check_all', function() {
@ -55,26 +56,28 @@ function updateFuzzyTimes(locale) {
}
function updatePage(url) {
setInterval(function () {
$.ajax({
url: url,
dataType: 'html'
}).done(function (data) {
$data = $(data)
$.ajax({
url: url,
dataType: 'html'
}).done(function(data) {
$data = $(data)
var $page = $data.filter('#page')
$('#page').replaceWith($page)
var $page = $data.filter('#page')
$('#page').replaceWith($page)
var $header_status = $data.find('.status')
$('.status').replaceWith($header_status)
var $header_status = $data.find('.status')
$('.status').replaceWith($header_status)
updateFuzzyTimes($('body').data('locale'));
})
}, parseInt(localStorage.timeInterval) || 2000);
updateFuzzyTimes($('body').data('locale'));
var ti = parseInt(localStorage.timeInterval) || 2000;
setTimeout(function(){updatePage(url)}, ti)
}).fail(function() {
var ti = parseInt(localStorage.timeInterval) || 2000;
setTimeout(function(){updatePage(url)}, ti)
})
}
$(function() {
'use strict';