From 2b3baa27a8a58d5225ac4771f2d828f703afc110 Mon Sep 17 00:00:00 2001 From: Jiang Bohan Date: Tue, 3 Feb 2026 19:16:19 +0800 Subject: [PATCH] fix(desktop): add missing handleRefresh dependency to useEffect Fix ESLint warning for react-hooks/exhaustive-deps by moving handleRefresh definition before the useEffect that uses it. Co-Authored-By: Claude Opus 4.5 --- apps/desktop/src/components/qr-code.tsx | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/desktop/src/components/qr-code.tsx b/apps/desktop/src/components/qr-code.tsx index 35ba0d8d..f70f8ed2 100644 --- a/apps/desktop/src/components/qr-code.tsx +++ b/apps/desktop/src/components/qr-code.tsx @@ -84,21 +84,6 @@ export function ConnectionQRCode({ return `multica://connect?${params.toString()}` }, [gateway, hubId, agentId, token, expiresAt]) - // Countdown timer - useEffect(() => { - const timer = setInterval(() => { - const remaining = Math.max(0, Math.floor((expiresAt - Date.now()) / 1000)) - setRemainingSeconds(remaining) - - // Auto-refresh when expired - if (remaining === 0) { - handleRefresh() - } - }, 1000) - - return () => clearInterval(timer) - }, [expiresAt]) - // Refresh token handler const handleRefresh = useCallback(() => { const newToken = generateToken() @@ -120,6 +105,21 @@ export function ConnectionQRCode({ } }, [gateway, hubId, agentId, expirySeconds, onRefresh]) + // Countdown timer + useEffect(() => { + const timer = setInterval(() => { + const remaining = Math.max(0, Math.floor((expiresAt - Date.now()) / 1000)) + setRemainingSeconds(remaining) + + // Auto-refresh when expired + if (remaining === 0) { + handleRefresh() + } + }, 1000) + + return () => clearInterval(timer) + }, [expiresAt, handleRefresh]) + // Copy link handler const handleCopyLink = async () => { try {