Skip to content

Commit 75c0147

Browse files
committed
debounce user search
1 parent 43e8bb9 commit 75c0147

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

jupyterlab_leetcode/handlers/leetcode_handler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class LeetCodeHandler(BaseHandler):
2323
"""Base handler for LeetCode-related requests."""
2424

2525
async def prepare(self) -> None:
26+
"""Prepare the handler by checking for LeetCode cookies."""
2627
await super().prepare()
2728
if not self.settings.get("leetcode_headers"):
2829
browser = self.get_cookie("leetcode_browser")

src/components/QuestionQueryBar.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const QuestionQueryBar: React.FC<{
1212
placeholder="Search questions"
1313
mb="md"
1414
leftSection={<IconSearch size={16} stroke={1.5} />}
15-
value={query.keyword}
1615
onChange={e => updateQuery({ ...query, keyword: e.target.value })}
1716
/>
1817
);

src/components/QuestionTable.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { LeetCodeQuestion, LeetCodeQuestionQuery } from '../types/leetcode';
55
import QuestionItem from './QuestionItem';
66
import { Table, Text, Stack, ScrollArea, Skeleton } from '@mantine/core';
77
import QuestionQueryBar from './QuestionQueryBar';
8+
import { useDebouncedState } from '@mantine/hooks';
89

910
const QuestionTable: React.FC<{
1011
openNotebook: (p: string) => void;
@@ -19,7 +20,12 @@ const QuestionTable: React.FC<{
1920
const [_finishedLength, setFinishedLength] = useState(0);
2021
const [_totalLength, setTotalLength] = useState(0);
2122

22-
const [query, setQuery] = useState<LeetCodeQuestionQuery>({ keyword: '' });
23+
const [query, setQuery] = useDebouncedState<LeetCodeQuestionQuery>(
24+
{
25+
keyword: ''
26+
},
27+
100
28+
);
2329

2430
const updateQuery = (newQuery: LeetCodeQuestionQuery) => {
2531
setQuery(newQuery);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy