mirror of
https://github.com/stablyai/orca.git
synced 2026-09-28 08:02:43 +00:00
perf: reuse mounted ref in ssh status row (#3593)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import { AlertTriangle, Cloud, Loader2, MonitorSmartphone, Server, ServerOff } from 'lucide-react'
|
||||
import { toast } from 'sonner'
|
||||
import {
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from '@/components/ui/dropdown-menu'
|
||||
import { useMountedRef } from '@/hooks/useMountedRef'
|
||||
import { useAppStore } from '../../store'
|
||||
import { STATUS_LABELS, statusColor } from '../settings/SshTargetCard'
|
||||
import type { SshConnectionStatus } from '../../../../shared/ssh-types'
|
||||
@@ -113,16 +114,9 @@ function TargetRow({
|
||||
syncStatus: RemoteWorkspaceSyncStatus | undefined
|
||||
}): React.JSX.Element {
|
||||
const [busy, setBusy] = useState(false)
|
||||
const mountedRef = useRef(true)
|
||||
const mountedRef = useMountedRef()
|
||||
const recordFeatureInteraction = useAppStore((s) => s.recordFeatureInteraction)
|
||||
|
||||
useEffect(() => {
|
||||
mountedRef.current = true
|
||||
return () => {
|
||||
mountedRef.current = false
|
||||
}
|
||||
}, [])
|
||||
|
||||
const handleConnect = useCallback(async () => {
|
||||
setBusy(true)
|
||||
try {
|
||||
@@ -135,7 +129,7 @@ function TargetRow({
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
}, [recordFeatureInteraction, targetId])
|
||||
}, [mountedRef, recordFeatureInteraction, targetId])
|
||||
|
||||
const handleDisconnect = useCallback(async () => {
|
||||
setBusy(true)
|
||||
@@ -149,7 +143,7 @@ function TargetRow({
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
}, [recordFeatureInteraction, targetId])
|
||||
}, [mountedRef, recordFeatureInteraction, targetId])
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2.5 px-2 py-1.5">
|
||||
|
||||
Reference in New Issue
Block a user