mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-03-03 21:17:50 +00:00
fix(git-panel): improve commit expansion logic and fetch diff condition
This commit is contained in:
@@ -24,21 +24,24 @@ export default function HistoryView({
|
|||||||
|
|
||||||
const toggleCommitExpanded = useCallback(
|
const toggleCommitExpanded = useCallback(
|
||||||
(commitHash: string) => {
|
(commitHash: string) => {
|
||||||
|
const isExpanding = !expandedCommits.has(commitHash);
|
||||||
|
|
||||||
setExpandedCommits((previous) => {
|
setExpandedCommits((previous) => {
|
||||||
const next = new Set(previous);
|
const next = new Set(previous);
|
||||||
if (next.has(commitHash)) {
|
if (next.has(commitHash)) {
|
||||||
next.delete(commitHash);
|
next.delete(commitHash);
|
||||||
} else {
|
} else {
|
||||||
next.add(commitHash);
|
next.add(commitHash);
|
||||||
// Load commit diff lazily only the first time a commit is expanded.
|
|
||||||
if (!commitDiffs[commitHash]) {
|
|
||||||
void onFetchCommitDiff(commitHash);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return next;
|
return next;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Load commit diff lazily only the first time a commit is expanded.
|
||||||
|
if (isExpanding && !commitDiffs[commitHash]) {
|
||||||
|
void onFetchCommitDiff(commitHash);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[commitDiffs, onFetchCommitDiff],
|
[commitDiffs, expandedCommits, onFetchCommitDiff, setExpandedCommits],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user