From 112bdcf2d0c4825b05d85fac637f00241d4af7de Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Sat, 15 Apr 2017 07:14:09 +0000 Subject: [PATCH] Stop fetching when already is fetching --- titanembeds/static/js/embed.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/titanembeds/static/js/embed.js b/titanembeds/static/js/embed.js index 8a5d0d7..e5aa108 100644 --- a/titanembeds/static/js/embed.js +++ b/titanembeds/static/js/embed.js @@ -8,6 +8,7 @@ (function () { var logintimer; // timer to keep track of user inactivity after hitting login var fetchtimeout; // fetch routine timer + var currently_fetching; // fetch lock- if true, do not fetch var last_message_id; // last message tracked var selected_channel = guild_id; // user selected channel, defaults to #general channel var guild_channels = {}; // all server channels used to highlight channels in messages @@ -200,7 +201,7 @@ } guild_members_arr.sort(function(a, b) { return parseInt(b.position) - parseInt(a.position); - }) + }); var template_role = $('#mustache_memberrole').html(); Mustache.parse(template_role); var template_user = $('#mustache_authedusers').html(); @@ -388,6 +389,10 @@ } function run_fetch_routine() { + if (currently_fetching) { + return; + } + currently_fetching = true; var channel_id = selected_channel; var fet; var jumpscroll; @@ -432,6 +437,9 @@ fetchtimeout = setTimeout(run_fetch_routine, 10000); } }); + fet.always(function() { + currently_fetching = false; + }); } function update_embed_userchip(authenticated, avatar, username, userid, discrim=null) {