Files
tolaria/src/hooks/useGitHistory.ts
Luca Rossi ae3657d19c refactor: extract hooks from App.tsx to improve code health (#62)
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>
2026-02-25 13:31:19 +01:00

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 : []
}