From 1994ba4e86380a91984c31fffd6a6d635e893f20 Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Sat, 29 Apr 2017 00:10:01 -0700 Subject: [PATCH] Show fetching message error on fives to prevent clutter --- titanembeds/static/js/embed.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/titanembeds/static/js/embed.js b/titanembeds/static/js/embed.js index 6d0e32c..db9c5ee 100644 --- a/titanembeds/static/js/embed.js +++ b/titanembeds/static/js/embed.js @@ -13,6 +13,7 @@ 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 + var fetch_error_count = 0; // Number of errors fetch has encountered function element_in_view(element, fullyInView) { var pageTop = $(window).scrollTop(); @@ -449,7 +450,10 @@ }); fet.catch(function(data) { if (500 <= data.status && data.status < 600) { - Materialize.toast('Fetching messages error! EndenDragon probably broke something. Sorry =(', 10000); + if (fetch_error_count % 5 == 0) { + Materialize.toast('Fetching messages error! EndenDragon probably broke something. Sorry =(', 10000); + } + fetch_error_count += 1; fetchtimeout = setTimeout(run_fetch_routine, 10000); } });