ui fix: prevent race condition with popover trophy update

pull/7/head
Sami Mokaddem 2017-11-21 11:08:08 +01:00
parent 49c21b14a1
commit a4655fce49
1 changed files with 17 additions and 10 deletions

View File

@ -527,17 +527,24 @@ function updateProgressHeader(org) {
categ = trophy_categ_list[i];
$('#trophy_'+categ).attr('src', source);
$('#trophy_'+categ).attr('title', "");
$('#trophy_'+categ).popover("destroy")
}
for(var i=0; i<data.length; i++) { // add
categ = data[i].categ;
rank = data[i].trophy_true_rank;
trophy_points = data[i].trophy_points
source = url_baseTrophyLogo+rank+'.png'
$('#trophy_'+categ).attr('src', source);
$('#trophy_'+categ).attr('title', trophy_title[rank]);
$('#trophy_'+categ).popover({title: trophy_title[rank], content: 'Level: '+rank+' ('+trophy_points+' points)', trigger: "hover", placement: "bottom"});
try { // in case popover not created
var pop = $('#trophy_'+categ).data('bs.popover');
pop.destroy();
} catch(err) {
}
}
setTimeout(function() { // avoid race condition with destroy
for(var i=0; i<data.length; i++) { // add
categ = data[i].categ;
rank = data[i].trophy_true_rank;
trophy_points = data[i].trophy_points
source = url_baseTrophyLogo+rank+'.png'
$('#trophy_'+categ).attr('src', source);
$('#trophy_'+categ).attr('title', trophy_title[rank]);
$('#trophy_'+categ).popover({title: trophy_title[rank], content: 'Level: '+rank+' ('+trophy_points+' points)', trigger: "hover", placement: "bottom"});
}
}, 300);
});
//update overtake points