Skip to content

Commit

Permalink
Remove throttling on Slider level
Browse files Browse the repository at this point in the history
  • Loading branch information
selinali2010 committed Feb 16, 2023
1 parent 366a4d4 commit fd57123
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/renderer/components/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useCallback, useEffect, useState } from 'react';
import NumberInput from '../widgets/NumberInput';
import RangeInput from '../widgets/RangeInput';
import { useAquaContext } from '../utils/AquaContext';
import { useThrottle } from '../utils/utils';
import '../styles/Slider.scss';

interface ISliderProps {
Expand All @@ -24,7 +23,6 @@ const Slider = ({
label,
setValue,
}: ISliderProps) => {
const INTERVAL = 100;
const { globalError } = useAquaContext();

// Local copy of slider value used so that the number input increases smoothly while throttling EQ APO writes
Expand All @@ -47,18 +45,6 @@ const Slider = ({
handleChangeValue(newValue);
};

const throttledSetValue = useThrottle(handleChangeValue, INTERVAL);

// Helpers for adjusting the preAmp gain value
const handleChangeValueWithThrottle = async (newValue: number) => {
setSliderValue(newValue);
throttledSetValue(newValue);
};
const handleChangeValueWithoutThrottle = async (newValue: number) => {
setSliderValue(newValue);
handleChangeValue(newValue);
};

return (
<div className="col center slider">
<RangeInput
Expand All @@ -67,8 +53,8 @@ const Slider = ({
min={min}
max={max}
height={sliderHeight}
handleChange={handleChangeValueWithThrottle}
handleMouseUp={handleChangeValueWithoutThrottle}
handleChange={handleInput}
handleMouseUp={handleInput}
isDisabled={!!globalError}
incrementPrecision={0}
displayPrecision={2}
Expand Down

0 comments on commit fd57123

Please sign in to comment.