Stop fetching when already is fetching

This commit is contained in:
Jeremy Zhang 2017-04-15 07:14:09 +00:00
parent 38ff5f2767
commit 112bdcf2d0

View File

@ -8,6 +8,7 @@
(function () { (function () {
var logintimer; // timer to keep track of user inactivity after hitting login var logintimer; // timer to keep track of user inactivity after hitting login
var fetchtimeout; // fetch routine timer var fetchtimeout; // fetch routine timer
var currently_fetching; // fetch lock- if true, do not fetch
var last_message_id; // last message tracked var last_message_id; // last message tracked
var selected_channel = guild_id; // user selected channel, defaults to #general channel var selected_channel = guild_id; // user selected channel, defaults to #general channel
var guild_channels = {}; // all server channels used to highlight channels in messages var guild_channels = {}; // all server channels used to highlight channels in messages
@ -200,7 +201,7 @@
} }
guild_members_arr.sort(function(a, b) { guild_members_arr.sort(function(a, b) {
return parseInt(b.position) - parseInt(a.position); return parseInt(b.position) - parseInt(a.position);
}) });
var template_role = $('#mustache_memberrole').html(); var template_role = $('#mustache_memberrole').html();
Mustache.parse(template_role); Mustache.parse(template_role);
var template_user = $('#mustache_authedusers').html(); var template_user = $('#mustache_authedusers').html();
@ -388,6 +389,10 @@
} }
function run_fetch_routine() { function run_fetch_routine() {
if (currently_fetching) {
return;
}
currently_fetching = true;
var channel_id = selected_channel; var channel_id = selected_channel;
var fet; var fet;
var jumpscroll; var jumpscroll;
@ -432,6 +437,9 @@
fetchtimeout = setTimeout(run_fetch_routine, 10000); fetchtimeout = setTimeout(run_fetch_routine, 10000);
} }
}); });
fet.always(function() {
currently_fetching = false;
});
} }
function update_embed_userchip(authenticated, avatar, username, userid, discrim=null) { function update_embed_userchip(authenticated, avatar, username, userid, discrim=null) {