From 99706839a89a4190a57f0466ccfe7d922dd59a96 Mon Sep 17 00:00:00 2001 From: filip131311 Date: Mon, 10 Jun 2024 11:53:07 +0200 Subject: [PATCH] remove unnecessery utill function --- packages/vscode-extension/src/common/utils.ts | 22 ------------------- .../src/webview/views/DeviceLocationView.tsx | 7 ++---- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/packages/vscode-extension/src/common/utils.ts b/packages/vscode-extension/src/common/utils.ts index 56f325206..b23f38234 100644 --- a/packages/vscode-extension/src/common/utils.ts +++ b/packages/vscode-extension/src/common/utils.ts @@ -27,25 +27,3 @@ export function throttle any>( recentArgs = args; } as T; } - -export function throttleWithTrailing any>( - func: T, - limitMs: number -): (...args: Parameters) => void { - let timeout: NodeJS.Timeout | null = null; - let recentArgs: any; - - return function (...args: Parameters) { - recentArgs = args; - - if (!timeout) { - timeout = setTimeout(() => { - timeout = null; - if (recentArgs) { - func(...recentArgs); - recentArgs = null; - } - }, limitMs); - } - }; -} diff --git a/packages/vscode-extension/src/webview/views/DeviceLocationView.tsx b/packages/vscode-extension/src/webview/views/DeviceLocationView.tsx index de0de2a45..41be8ed1a 100644 --- a/packages/vscode-extension/src/webview/views/DeviceLocationView.tsx +++ b/packages/vscode-extension/src/webview/views/DeviceLocationView.tsx @@ -4,8 +4,8 @@ import "./DeviceLocationView.css"; import Label from "../components/shared/Label"; import * as Switch from "@radix-ui/react-switch"; import CoordinateParser from "coordinate-parser"; -import { throttleWithTrailing } from "../../common/utils"; import Tooltip from "../components/shared/Tooltip"; +import { throttle } from "../../common/utils"; const CoordinateInfo = () => { return ( @@ -43,10 +43,7 @@ export function DeviceLocationView() { const { project, deviceSettings } = useProject(); const inputRef = useRef(null); - const updateProjectSettingWithThrottle = throttleWithTrailing( - project.updateDeviceSettings, - THROTTLE_LIMIT - ); + const updateProjectSettingWithThrottle = throttle(project.updateDeviceSettings, THROTTLE_LIMIT); const [isCoordinateValid, setIsCoordinateValid] = useState(true);