If in viewer load latest file in viewer (#5784)

This commit is contained in:
Reece Browne
2026-02-23 22:33:43 +00:00
committed by GitHub
parent d3494e3287
commit 4f4d93d028
2 changed files with 26 additions and 33 deletions
+11 -23
View File
@@ -13,37 +13,25 @@ export function getStartupNavigationAction(
selectedToolKey: string | null,
currentWorkbench: WorkbenchType
): StartupNavigationAction | null {
console.log('[homePageNavigation] Called with:', {
previousFileCount,
currentFileCount,
selectedToolKey,
currentWorkbench,
});
// pdfTextEditor handles its own empty state
if (selectedToolKey === 'pdfTextEditor') {
console.log('[homePageNavigation] pdfTextEditor detected, returning null');
return null;
}
// Only handle transitions from empty (0 files) to some files
if (previousFileCount !== 0) {
console.log('[homePageNavigation] Not a 0→N transition, returning null');
return null;
// Already actively viewing in the viewer → update to the latest file
if (previousFileCount > 0 && currentWorkbench === 'viewer' && currentFileCount > previousFileCount) {
return { workbench: 'viewer', activeFileIndex: currentFileCount - 1 };
}
// 0→1: Go to viewer to view the single file
if (currentFileCount === 1) {
console.log('[homePageNavigation] 0→1 transition, returning viewer');
return { workbench: 'viewer', activeFileIndex: 0 };
// From landing page (no prior files)
if (previousFileCount === 0) {
if (currentFileCount === 1) {
return { workbench: 'viewer', activeFileIndex: 0 };
}
if (currentFileCount > 1) {
return { workbench: 'fileEditor' };
}
}
// 0→N (N>1): Go to fileEditor to manage multiple files
if (currentFileCount > 1) {
console.log('[homePageNavigation] 0→N transition, returning fileEditor');
return { workbench: 'fileEditor' };
}
console.log('[homePageNavigation] Still at 0 files, returning null');
return null;
}