Extract vault management (useVaultSwitcher), git history loading (useGitHistory), dialog state (useDialogs), and keyboard/command setup (useAppCommands) into dedicated hooks. App.tsx code health improves from 8.95 to 10.0 — all extracted hooks also score 10.0. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
14 lines
457 B
TypeScript
14 lines
457 B
TypeScript
import { useEffect, useState } from 'react'
|
|
import type { GitCommit } from '../types'
|
|
|
|
export function useGitHistory(activeTabPath: string | null, loadGitHistory: (path: string) => Promise<GitCommit[]>) {
|
|
const [gitHistory, setGitHistory] = useState<GitCommit[]>([])
|
|
|
|
useEffect(() => {
|
|
if (!activeTabPath) return
|
|
loadGitHistory(activeTabPath).then(setGitHistory)
|
|
}, [activeTabPath, loadGitHistory])
|
|
|
|
return activeTabPath ? gitHistory : []
|
|
}
|