From 3315c607890a676b4829eb81c2cd918b5833d65a Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Mon, 13 Jan 2020 08:14:16 -0500 Subject: [PATCH] prevent setInterval calls from queueing --- assets/js/notifications.js | 6 ++++-- lib/mix/tasks/reindex_all.ex | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/assets/js/notifications.js b/assets/js/notifications.js index 1ec35615..11806a6f 100644 --- a/assets/js/notifications.js +++ b/assets/js/notifications.js @@ -33,6 +33,8 @@ function getNewNotifications() { makeRequest('GET').then(response => response.json()).then(({ notifications }) => { updateNotificationTicker(notifications); storeNotificationCount(notifications); + + setTimeout(getNewNotifications, NOTIFICATION_INTERVAL); }); } @@ -55,7 +57,7 @@ function setupNotifications() { if (!window.booru.userIsSignedIn) return; // Fetch notifications from the server at a regular interval - setInterval(getNewNotifications, NOTIFICATION_INTERVAL); + setTimeout(getNewNotifications, NOTIFICATION_INTERVAL); // Update the current number of notifications based on the latest page load storeNotificationCount($('.js-notification-ticker').dataset.notificationCount); @@ -66,4 +68,4 @@ function setupNotifications() { bindSubscriptionLinks(); } -export { setupNotifications }; \ No newline at end of file +export { setupNotifications }; diff --git a/lib/mix/tasks/reindex_all.ex b/lib/mix/tasks/reindex_all.ex index cc7383b8..e77e1dd4 100644 --- a/lib/mix/tasks/reindex_all.ex +++ b/lib/mix/tasks/reindex_all.ex @@ -19,7 +19,7 @@ defmodule Mix.Tasks.ReindexAll do @shortdoc "Destroys and recreates all Elasticsearch indices." def run(_) do - if Mix.env() == "prod" do + if Mix.env() == :prod do raise "do not run this task in production" end