Fixed filters bug

This commit is contained in:
Jan Zípek 2022-09-04 11:16:29 +02:00
parent 722c9e777a
commit 9be5dc8281
Signed by: kamen
GPG Key ID: A17882625B33AC31
1 changed files with 7 additions and 3 deletions

View File

@ -1,6 +1,7 @@
import { DateTimeInput } from '@/components/DateTimeInput'
import { useFilterIntervals } from '@/pages/dashboard/hooks/useFilterIntervals'
import { intervalToRange } from '@/utils/intervalToRange'
import { nextFrame } from '@/utils/nextFrame'
import { useEffect, useState } from 'preact/hooks'
import { useDashboardContext } from '../../../contexts/DashboardContext'
@ -41,11 +42,14 @@ export const DashboardFilters = ({ onClose }: Props) => {
onClose?.()
}
const setInterval = (interval: FilterInterval) => {
const setInterval = async (interval: FilterInterval) => {
const range = intervalToRange(interval, value.customFrom, value.customTo)
setValue({
...value,
// preact bug again - starting to regret using it
await nextFrame()
setFilter({
...preset,
interval,
customFrom: range[0],
customTo: range[1],