Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rmburg committed Apr 28, 2024
1 parent 5d2b5d1 commit cee7070
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
22 changes: 12 additions & 10 deletions src/routes/demos/demoDir/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,25 @@ import { IconSearch } from "@tabler/icons-react";
import classes from "./SearchInput.module.css";

type SearchInputProps = {
initialQuery: string;
setDebouncedQuery(newQuery: string): void;
query: string;
setQuery(newQuery: string): void;
debounceInterval: number;
};

export default function SearchInput({
initialQuery,
setDebouncedQuery,
query,
setQuery,
debounceInterval,
}: SearchInputProps) {
const [query, setQuery] = useState(initialQuery);
const [rawQuery, setRawQuery] = useState(query);

const [debouncedQuery] = useDebouncedValue(query, debounceInterval);
const [debouncedQuery] = useDebouncedValue(rawQuery, debounceInterval);

useEffect(() => {
setDebouncedQuery(debouncedQuery);
}, [debouncedQuery]);
if (rawQuery != query) {
setQuery(debouncedQuery);
}
}, [setQuery, debouncedQuery, query, rawQuery]);

return (
<Input
Expand All @@ -32,9 +34,9 @@ export default function SearchInput({
size="sm"
leftSection={<IconSearch size={18} />}
classNames={{ input: classes.input, wrapper: classes.wrapper }}
value={query}
value={rawQuery}
onChange={(event) => {
setQuery(event.currentTarget.value);
setRawQuery(event.currentTarget.value);
}}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion src/routes/demos/demoDir/demoDetails/Highlights.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export default function HighlightsList({ gameSummary }: TimelineProps) {
const highlights = useMemo(
() =>
filterHighlights(gameSummary.highlights, filters, gameSummary.aliases),
[gameSummary.highlights, filters]
[gameSummary, filters]
);

return (
Expand Down
6 changes: 2 additions & 4 deletions src/routes/demos/demoDir/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ export default () => {
sortOrder: "descending" as SortOrder,
});

console.log(locationState);

const filters: DemoFilter[] = [];

return (
Expand All @@ -88,8 +86,8 @@ export default () => {
<HeaderBar
center={
<SearchInput
initialQuery={locationState.query}
setDebouncedQuery={setLocationState("query")}
query={locationState.query}
setQuery={setLocationState("query")}
debounceInterval={500}
/>
}
Expand Down

0 comments on commit cee7070

Please sign in to comment.