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;
|
fileHistoryCollapsed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hideAndResetFileHistory() {
|
||||||
|
fileHistoryRequestId += 1;
|
||||||
|
cancelActiveFileHistoryLoad();
|
||||||
|
activeFileHistoryRequestId = "";
|
||||||
|
fileHistoryLoading = false;
|
||||||
|
fileHistory = [];
|
||||||
|
fileHistoryCollapsed = true;
|
||||||
|
}
|
||||||
|
|
||||||
function rememberRecentRepo(path: string) {
|
function rememberRecentRepo(path: string) {
|
||||||
recentRepoPaths = uniqueRepoPaths([path, ...recentRepoPaths]).slice(0, 40);
|
recentRepoPaths = uniqueRepoPaths([path, ...recentRepoPaths]).slice(0, 40);
|
||||||
persistRepoLists();
|
persistRepoLists();
|
||||||
@@ -1818,7 +1827,7 @@
|
|||||||
await refreshBranchList(path);
|
await refreshBranchList(path);
|
||||||
await refreshTags(path);
|
await refreshTags(path);
|
||||||
await refreshCommitHistory(path);
|
await refreshCommitHistory(path);
|
||||||
if (lastFileHistoryHeadHash !== previousHeadHash) {
|
if (lastFileHistoryHeadHash !== previousHeadHash && !fileHistoryCollapsed) {
|
||||||
await refreshFileHistory(path);
|
await refreshFileHistory(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3262,7 +3271,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function selectExplorerNode(node: ExplorerNode) {
|
async function selectExplorerNode(node: ExplorerNode) {
|
||||||
if (!activeRepoPath || (selectedExplorerPath === node.path && selectedExplorerKind === node.kind)) return;
|
if (!activeRepoPath) return;
|
||||||
selectedExplorerPath = node.path;
|
selectedExplorerPath = node.path;
|
||||||
selectedExplorerKind = node.kind;
|
selectedExplorerKind = node.kind;
|
||||||
revealFileHistory();
|
revealFileHistory();
|
||||||
@@ -3292,9 +3301,7 @@
|
|||||||
selectedExplorerPath = file.path;
|
selectedExplorerPath = file.path;
|
||||||
selectedExplorerKind = "file";
|
selectedExplorerKind = "file";
|
||||||
expandedExplorerPaths = new Set([...expandedExplorerPaths, ...explorerParentFolders(file.path)]);
|
expandedExplorerPaths = new Set([...expandedExplorerPaths, ...explorerParentFolders(file.path)]);
|
||||||
revealFileHistory();
|
hideAndResetFileHistory();
|
||||||
|
|
||||||
void loadSelectedFileHistory(file.path);
|
|
||||||
trackEvent("explorer_file_selected", {
|
trackEvent("explorer_file_selected", {
|
||||||
source: "status",
|
source: "status",
|
||||||
status: file.unstaged ?? file.staged ?? "unknown",
|
status: file.unstaged ?? file.staged ?? "unknown",
|
||||||
|
|||||||
Reference in New Issue
Block a user