refactor(explorer): improve file history state management
Adjusts the logic governing when file history views are refreshed or displayed. This ensures that selecting a file via the explorer correctly hides any active file history view, and prevents unnecessary refreshes of history data if the view is already collapsed or if the repository path is not yet set. - Added explicit function to reset file history state - Prevents automatic display of file history upon file selection - Refines conditions for refreshing file history during repo updates
This commit is contained in:
+12
-5
@@ -1612,6 +1612,15 @@
|
||||
fileHistoryCollapsed = false;
|
||||
}
|
||||
|
||||
function hideAndResetFileHistory() {
|
||||
fileHistoryRequestId += 1;
|
||||
cancelActiveFileHistoryLoad();
|
||||
activeFileHistoryRequestId = "";
|
||||
fileHistoryLoading = false;
|
||||
fileHistory = [];
|
||||
fileHistoryCollapsed = true;
|
||||
}
|
||||
|
||||
function rememberRecentRepo(path: string) {
|
||||
recentRepoPaths = uniqueRepoPaths([path, ...recentRepoPaths]).slice(0, 40);
|
||||
persistRepoLists();
|
||||
@@ -1818,7 +1827,7 @@
|
||||
await refreshBranchList(path);
|
||||
await refreshTags(path);
|
||||
await refreshCommitHistory(path);
|
||||
if (lastFileHistoryHeadHash !== previousHeadHash) {
|
||||
if (lastFileHistoryHeadHash !== previousHeadHash && !fileHistoryCollapsed) {
|
||||
await refreshFileHistory(path);
|
||||
}
|
||||
}
|
||||
@@ -3262,7 +3271,7 @@
|
||||
}
|
||||
|
||||
async function selectExplorerNode(node: ExplorerNode) {
|
||||
if (!activeRepoPath || (selectedExplorerPath === node.path && selectedExplorerKind === node.kind)) return;
|
||||
if (!activeRepoPath) return;
|
||||
selectedExplorerPath = node.path;
|
||||
selectedExplorerKind = node.kind;
|
||||
revealFileHistory();
|
||||
@@ -3292,9 +3301,7 @@
|
||||
selectedExplorerPath = file.path;
|
||||
selectedExplorerKind = "file";
|
||||
expandedExplorerPaths = new Set([...expandedExplorerPaths, ...explorerParentFolders(file.path)]);
|
||||
revealFileHistory();
|
||||
|
||||
void loadSelectedFileHistory(file.path);
|
||||
hideAndResetFileHistory();
|
||||
trackEvent("explorer_file_selected", {
|
||||
source: "status",
|
||||
status: file.unstaged ?? file.staged ?? "unknown",
|
||||
|
||||
Reference in New Issue
Block a user