From 3a8e45fba291f0d94b6f35f7777dae5bc38c31a8 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 10 Sep 2022 12:07:47 -0500 Subject: [PATCH] Delete unused schedule_idle_task.js --- .../features/ui/util/schedule_idle_task.js | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 app/soapbox/features/ui/util/schedule_idle_task.js diff --git a/app/soapbox/features/ui/util/schedule_idle_task.js b/app/soapbox/features/ui/util/schedule_idle_task.js deleted file mode 100644 index b04d4a8ee..000000000 --- a/app/soapbox/features/ui/util/schedule_idle_task.js +++ /dev/null @@ -1,29 +0,0 @@ -// Wrapper to call requestIdleCallback() to schedule low-priority work. -// See https://developer.mozilla.org/en-US/docs/Web/API/Background_Tasks_API -// for a good breakdown of the concepts behind this. - -import Queue from 'tiny-queue'; - -const taskQueue = new Queue(); -let runningRequestIdleCallback = false; - -function runTasks(deadline) { - while (taskQueue.length && deadline.timeRemaining() > 0) { - taskQueue.shift()(); - } - if (taskQueue.length) { - requestIdleCallback(runTasks); - } else { - runningRequestIdleCallback = false; - } -} - -function scheduleIdleTask(task) { - taskQueue.push(task); - if (!runningRequestIdleCallback) { - runningRequestIdleCallback = true; - requestIdleCallback(runTasks); - } -} - -export default scheduleIdleTask;