Less query guild

This commit is contained in:
Jeremy Zhang 2017-04-24 23:52:46 -07:00
parent 53b4c1f2f8
commit a0e8ac1e9d

View File

@ -12,6 +12,7 @@
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
var times_fetched = 0; // kept track of how many times that it has fetched
function element_in_view(element, fullyInView) { function element_in_view(element, fullyInView) {
var pageTop = $(window).scrollTop(); var pageTop = $(window).scrollTop();
@ -418,14 +419,18 @@
} else { } else {
$("#administrate_link").hide(); $("#administrate_link").hide();
} }
var guild = query_guild(); if (times_fetched % 10 == 0) {
guild.done(function(guildobj) { var guild = query_guild();
fill_channels(guildobj.channels); guild.done(function(guildobj) {
fill_discord_members(guildobj.discordmembers); fill_channels(guildobj.channels);
fill_authenticated_users(guildobj.embedmembers.authenticated); fill_discord_members(guildobj.discordmembers);
fill_unauthenticated_users(guildobj.embedmembers.unauthenticated); fill_authenticated_users(guildobj.embedmembers.authenticated);
fetchtimeout = setTimeout(run_fetch_routine, 5000); fill_unauthenticated_users(guildobj.embedmembers.unauthenticated);
}); fetchtimeout = setTimeout(run_fetch_routine, 5000);
});
} else {
fetchtimeout = setTimeout(run_fetch_routine, 5000);
}
}); });
fet.fail(function(data) { fet.fail(function(data) {
if (data.status == 403) { if (data.status == 403) {
@ -438,12 +443,13 @@
}); });
fet.catch(function(data) { fet.catch(function(data) {
if (500 <= data.status && data.status < 600) { if (500 <= data.status && data.status < 600) {
Materialize.toast('Fetching messages error! Webserver down?', 10000); Materialize.toast('Fetching messages error! EndenDragon probably broke something. Sorry =(', 10000);
fetchtimeout = setTimeout(run_fetch_routine, 10000); fetchtimeout = setTimeout(run_fetch_routine, 10000);
} }
}); });
fet.always(function() { fet.always(function() {
currently_fetching = false; currently_fetching = false;
times_fetched += 1;
}); });
} }