From b2a3cb0d1687b782084089a15d50d69dd9f92060 Mon Sep 17 00:00:00 2001 From: Max G Date: Mon, 6 Oct 2025 02:39:14 +0200 Subject: [PATCH 1/3] faet(load-game): auto-prefill latest username Signed-off-by: Max G --- src/sections/loadGame/chessComInput.tsx | 2 +- src/sections/loadGame/lichessInput.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sections/loadGame/chessComInput.tsx b/src/sections/loadGame/chessComInput.tsx index 1223c02f..05e1e2ff 100644 --- a/src/sections/loadGame/chessComInput.tsx +++ b/src/sections/loadGame/chessComInput.tsx @@ -23,7 +23,7 @@ export default function ChessComInput({ onSelect }: Props) { "chesscom-username", "" ); - const [chessComUsername, setChessComUsername] = useState(""); + const [chessComUsername, setChessComUsername] = useState(rawStoredValue?.split(",")[0] ?? ""); const [hasEdited, setHasEdited] = useState(false); const storedValues = useMemo(() => { diff --git a/src/sections/loadGame/lichessInput.tsx b/src/sections/loadGame/lichessInput.tsx index eab76cd2..99c06d40 100644 --- a/src/sections/loadGame/lichessInput.tsx +++ b/src/sections/loadGame/lichessInput.tsx @@ -23,7 +23,7 @@ export default function LichessInput({ onSelect }: Props) { "lichess-username", "" ); - const [lichessUsername, setLichessUsername] = useState(""); + const [lichessUsername, setLichessUsername] = useState(rawStoredValue?.split(",")[0] ?? ""); const [hasEdited, setHasEdited] = useState(false); const storedValues = useMemo(() => { From d1aeba5a430756c54afe35b08940b59febd370c4 Mon Sep 17 00:00:00 2001 From: Max G Date: Mon, 6 Oct 2025 02:46:02 +0200 Subject: [PATCH 2/3] feat(load-game): use cached react-query data Signed-off-by: Max G --- src/sections/loadGame/chessComInput.tsx | 7 +++++-- src/sections/loadGame/lichessInput.tsx | 9 ++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/sections/loadGame/chessComInput.tsx b/src/sections/loadGame/chessComInput.tsx index 05e1e2ff..b3440d30 100644 --- a/src/sections/loadGame/chessComInput.tsx +++ b/src/sections/loadGame/chessComInput.tsx @@ -74,7 +74,8 @@ export default function ChessComInput({ onSelect }: Props) { const { data: games, - isFetching, + isRefetching, + isLoading, isError, } = useQuery({ queryKey: ["CCUserGames", debouncedUsername], @@ -128,6 +129,8 @@ export default function ChessComInput({ onSelect }: Props) { /> + {isRefetching && } + {debouncedUsername && ( - {isFetching ? ( + {isLoading ? ( ) : isError ? ( diff --git a/src/sections/loadGame/lichessInput.tsx b/src/sections/loadGame/lichessInput.tsx index 99c06d40..3e75f5b0 100644 --- a/src/sections/loadGame/lichessInput.tsx +++ b/src/sections/loadGame/lichessInput.tsx @@ -23,7 +23,7 @@ export default function LichessInput({ onSelect }: Props) { "lichess-username", "" ); - const [lichessUsername, setLichessUsername] = useState(rawStoredValue?.split(",")[0] ?? ""); +const [lichessUsername, setLichessUsername] = useState(rawStoredValue?.split(",")[0] ?? ""); const [hasEdited, setHasEdited] = useState(false); const storedValues = useMemo(() => { @@ -73,7 +73,8 @@ export default function LichessInput({ onSelect }: Props) { const { data: games, - isFetching, + isLoading, + isRefetching, isError, } = useQuery({ queryKey: ["LichessUserGames", debouncedUsername], @@ -127,6 +128,8 @@ export default function LichessInput({ onSelect }: Props) { /> + {isRefetching && } + {debouncedUsername && ( - {isFetching ? ( + {isLoading ? ( ) : isError ? ( From 11dcbc360616459cebe450c8cbddc21d64b86e27 Mon Sep 17 00:00:00 2001 From: Max G Date: Mon, 6 Oct 2025 02:47:01 +0200 Subject: [PATCH 3/3] fix(load-game): make the username debounce equal Signed-off-by: Max G --- src/sections/loadGame/chessComInput.tsx | 2 +- src/sections/loadGame/lichessInput.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sections/loadGame/chessComInput.tsx b/src/sections/loadGame/chessComInput.tsx index b3440d30..1976ceb1 100644 --- a/src/sections/loadGame/chessComInput.tsx +++ b/src/sections/loadGame/chessComInput.tsx @@ -70,7 +70,7 @@ export default function ChessComInput({ onSelect }: Props) { setHasEdited(true); }; - const debouncedUsername = useDebounce(chessComUsername, 300); + const debouncedUsername = useDebounce(chessComUsername, 450); const { data: games, diff --git a/src/sections/loadGame/lichessInput.tsx b/src/sections/loadGame/lichessInput.tsx index 3e75f5b0..d0c4bfdd 100644 --- a/src/sections/loadGame/lichessInput.tsx +++ b/src/sections/loadGame/lichessInput.tsx @@ -69,7 +69,7 @@ const [lichessUsername, setLichessUsername] = useState(rawStoredValue?.split("," setHasEdited(true); }; - const debouncedUsername = useDebounce(lichessUsername, 500); + const debouncedUsername = useDebounce(lichessUsername, 450); const { data: games,