mirror of
https://github.com/stablyai/orca.git
synced 2026-09-28 08:02:43 +00:00
fix: guard landing async state (#3617)
This commit is contained in:
@@ -5,6 +5,7 @@ import { useAppStore } from '../store'
|
||||
import { isGitRepoKind } from '../../../shared/repo-kind'
|
||||
import { ShortcutKeyCombo } from './ShortcutKeyCombo'
|
||||
import { useShortcutKeys } from '@/hooks/useShortcutLabel'
|
||||
import { useMountedRef } from '@/hooks/useMountedRef'
|
||||
import logo from '../../../../resources/logo.svg'
|
||||
|
||||
type ShortcutItem = {
|
||||
@@ -64,6 +65,7 @@ function GitHubStarButton({ hasRepos }: { hasRepos: boolean }): React.JSX.Elemen
|
||||
const [state, setState] = useState<StarState>('loading')
|
||||
const [menuOpen, setMenuOpen] = useState(false)
|
||||
const wrapperRef = useRef<HTMLDivElement | null>(null)
|
||||
const mountedRef = useMountedRef()
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
@@ -106,7 +108,9 @@ function GitHubStarButton({ hasRepos }: { hasRepos: boolean }): React.JSX.Elemen
|
||||
setState('starred') // optimistic
|
||||
const ok = await window.api.gh.starOrca('landing')
|
||||
if (!ok) {
|
||||
setState('not-starred')
|
||||
if (mountedRef.current) {
|
||||
setState('not-starred')
|
||||
}
|
||||
return
|
||||
}
|
||||
// Why: starring from any entry point mutes the threshold-based nag.
|
||||
@@ -235,15 +239,22 @@ export default function Landing(): React.JSX.Element {
|
||||
return
|
||||
}
|
||||
|
||||
let cancelled = false
|
||||
// Why: some users complete `gh auth login` without ever leaving the Orca
|
||||
// window. Poll only while a warning is visible so the banner self-clears.
|
||||
const intervalId = window.setInterval(() => {
|
||||
void window.api.preflight.check({ force: true }).then((status) => {
|
||||
if (cancelled) {
|
||||
return
|
||||
}
|
||||
setPreflightIssues(getPreflightIssues(status))
|
||||
})
|
||||
}, 30000)
|
||||
|
||||
return () => window.clearInterval(intervalId)
|
||||
return () => {
|
||||
cancelled = true
|
||||
window.clearInterval(intervalId)
|
||||
}
|
||||
}, [preflightIssues.length])
|
||||
|
||||
const createWorktreeKeys = useShortcutKeys('workspace.create')
|
||||
|
||||
Reference in New Issue
Block a user