Fixed slider flicker issue when sliding in revese side (#2368)

zio/stable
Rahul Yadav 2024-01-03 22:38:21 +05:30 committed by GitHub
parent a410aad23c
commit 2c31e2a042
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -29,6 +29,7 @@ function RepliesThresholdInput({
const pal = usePalette('default')
const [value, setValue] = useState(initialValue)
const {mutate: setFeedViewPref} = useSetFeedViewPreferencesMutation()
const preValue = React.useRef(initialValue)
const save = React.useMemo(
() =>
debounce(
@ -46,7 +47,12 @@ function RepliesThresholdInput({
<Slider
value={value}
onValueChange={(v: number | number[]) => {
const threshold = Math.floor(Array.isArray(v) ? v[0] : v)
let threshold = Array.isArray(v) ? v[0] : v
if (threshold > preValue.current) threshold = Math.floor(threshold)
else threshold = Math.ceil(threshold)
preValue.current = threshold
setValue(threshold)
save(threshold)
}}