Skip to content

Commit

Permalink
filtering UX
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-codes committed Feb 6, 2024
1 parent bd6f81f commit 605e9ce
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions apps/playnite-web/src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Divider, TextField, styled } from '@mui/material'
import _ from 'lodash'
import { ChangeEvent, FC, PropsWithChildren, useCallback } from 'react'
import { useDispatch, useStore } from 'react-redux'
import { useDispatch } from 'react-redux'
import { setNameFilter } from '../api/client/state/librarySlice'

const { debounce } = _

const HeaderContainer = styled('header')(({ theme }) => ({
display: 'flex',
flexDirection: 'row',
Expand All @@ -20,12 +23,13 @@ const Header: FC<PropsWithChildren<{ showFilters?: boolean }>> = ({
children,
showFilters,
}) => {
const store = useStore()
console.dir(store.getState())
const dispatch = useDispatch()
const handleSearch = useCallback((event: ChangeEvent<HTMLInputElement>) => {
dispatch(setNameFilter(event.target.value))
}, [])
const handleSearch = useCallback(
debounce((event: ChangeEvent<HTMLInputElement>) => {
dispatch(setNameFilter(event.target.value))
}, 400),
[],
)

return (
<>
Expand Down

0 comments on commit 605e9ce

Please sign in to comment.