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 selected_channel = guild_id; // user selected channel, defaults to #general channel
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) {
var pageTop = $(window).scrollTop();
@ -418,6 +419,7 @@
} else {
$("#administrate_link").hide();
}
if (times_fetched % 10 == 0) {
var guild = query_guild();
guild.done(function(guildobj) {
fill_channels(guildobj.channels);
@ -426,6 +428,9 @@
fill_unauthenticated_users(guildobj.embedmembers.unauthenticated);
fetchtimeout = setTimeout(run_fetch_routine, 5000);
});
} else {
fetchtimeout = setTimeout(run_fetch_routine, 5000);
}
});
fet.fail(function(data) {
if (data.status == 403) {
@ -438,12 +443,13 @@
});
fet.catch(function(data) {
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);
}
});
fet.always(function() {
currently_fetching = false;
times_fetched += 1;
});
}