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 <noreply@anthropic.com>
This commit is contained in:
parent
4112d4511e
commit
2b3baa27a8
1 changed files with 15 additions and 15 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue