From 7c597be6c2c643e398fdeb732666fd9f1fd0f52c Mon Sep 17 00:00:00 2001 From: Panagiotis Georgakopoulos Date: Sun, 29 Nov 2020 21:43:33 +0200 Subject: [PATCH] Rename hook, var for debounce ms --- frontend/components/Cell.js | 2 +- frontend/components/{dropHandler.js => useDropHandler.js} | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) rename frontend/components/{dropHandler.js => useDropHandler.js} (98%) diff --git a/frontend/components/Cell.js b/frontend/components/Cell.js index 0777e17f05..0514f0cbee 100644 --- a/frontend/components/Cell.js +++ b/frontend/components/Cell.js @@ -4,7 +4,7 @@ import { CellOutput } from "./CellOutput.js" import { CellInput } from "./CellInput.js" import { RunArea, useMillisSinceTruthy } from "./RunArea.js" import { cl } from "../common/ClassTable.js" -import { useDropHandler } from "./dropHandler.js" +import { useDropHandler } from "./useDropHandler.js" /** * @typedef {Object} CodeState diff --git a/frontend/components/dropHandler.js b/frontend/components/useDropHandler.js similarity index 98% rename from frontend/components/dropHandler.js rename to frontend/components/useDropHandler.js index 6dc6693160..d8846748c0 100644 --- a/frontend/components/dropHandler.js +++ b/frontend/components/useDropHandler.js @@ -1,6 +1,7 @@ import { useState, useMemo } from "../imports/Preact.js" const MAGIC_TIMEOUT = 500 +const DEBOUNCE_MAGIC_MS = 250 const prepareFile = (file) => new Promise((resolve, reject) => { @@ -17,7 +18,7 @@ const prepareFile = (file) => export const useDropHandler = (requests, on_change, cell_id) => { const [savingFile, setSavingFile] = useState(false) const [dragActive, setDragActiveFast] = useState(false) - const setDragActive = useMemo(() => _.debounce(setDragActiveFast, 200), [setDragActiveFast]) + const setDragActive = useMemo(() => _.debounce(setDragActiveFast, DEBOUNCE_MAGIC_MS), [setDragActiveFast]) const inactiveHandler = useMemo( () => (ev) => { switch (ev.type) {