don't ask the server about profile cards if we already asked less than a minute ago

This commit is contained in:
Hannes Mannerheim 2016-01-20 18:30:16 +01:00
parent 965f40dc93
commit c44f7f4f41

View File

@ -330,6 +330,8 @@ function getUserArrayData(maybeProfileUrl,maybeNickname,timeNow,targetElement,ca
// hovers the element for, say, 200ms we ask the server if the link could be a remote profile
setTimeout(function(){
if(targetElement.is(":hover")) {
// don't try this if we already tried it less than a minute ago
if((typeof window.userArrayLastRetrieved[maybeProfileUrl] == 'undefined') || (timeNow - window.userArrayLastRetrieved[maybeProfileUrl]) > 60000) {
window.userArrayLastRetrieved[maybeProfileUrl] = timeNow;
getFromAPI('qvitter/external_user_show.json?profileurl=' + encodeURIComponent(maybeProfileUrl),function(data){
if(data && data.external !== null) {
@ -348,6 +350,7 @@ function getUserArrayData(maybeProfileUrl,maybeNickname,timeNow,targetElement,ca
}
});
}
}
},200);
}
// likely an uncached local profile