mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-05 18:20:39 -08:00
Update index.tsx
This commit is contained in:
parent
5115116427
commit
009e4ca848
1 changed files with 3 additions and 2 deletions
|
|
@ -226,8 +226,9 @@ export default function GitHistory(): React.JSX.Element {
|
||||||
}, [lastChangeType, entries, setSelectedCommit]);
|
}, [lastChangeType, entries, setSelectedCommit]);
|
||||||
|
|
||||||
// Maintain selection across refreshes by hash
|
// Maintain selection across refreshes by hash
|
||||||
|
// Skip if we should select first (manual commit) or if a commit just happened (auto-selection in progress)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedCommit && entries.length > 0) {
|
if (selectedCommit && entries.length > 0 && !shouldSelectFirst && lastChangeType !== 'commit') {
|
||||||
// Try to find the same commit in the new entries
|
// Try to find the same commit in the new entries
|
||||||
const stillExists = entries.find((entry) => entry.hash === selectedCommit.hash);
|
const stillExists = entries.find((entry) => entry.hash === selectedCommit.hash);
|
||||||
// Only update if data actually changed (compare by serialization)
|
// Only update if data actually changed (compare by serialization)
|
||||||
|
|
@ -236,7 +237,7 @@ export default function GitHistory(): React.JSX.Element {
|
||||||
setSelectedCommit(stillExists);
|
setSelectedCommit(stillExists);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [entries, selectedCommit]);
|
}, [entries, selectedCommit, shouldSelectFirst, lastChangeType]);
|
||||||
|
|
||||||
const handleCommitSuccess = () => {
|
const handleCommitSuccess = () => {
|
||||||
// Trigger selection of first commit after data refreshes
|
// Trigger selection of first commit after data refreshes
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue