fix: skip deleted entries in navigation history

This commit is contained in:
mirivlad 2026-06-06 02:42:20 +08:00
parent 0cd8a79049
commit 40c0953904
4 changed files with 42 additions and 13 deletions

View File

@ -19,7 +19,7 @@
background: #13131f; background: #13131f;
} }
</style> </style>
<script type="module" crossorigin src="/assets/main-2ehud8s_.js"></script> <script type="module" crossorigin src="/assets/main-DqAK36oG.js"></script>
<link rel="stylesheet" crossorigin href="/assets/main-N_NpVgn3.css"> <link rel="stylesheet" crossorigin href="/assets/main-N_NpVgn3.css">
</head> </head>
<body> <body>

View File

@ -304,14 +304,19 @@
try { try {
if (snapshot.nodeId) { if (snapshot.nodeId) {
const node = await wailsCall('GetNodeDetail', snapshot.nodeId) const node = await wailsCall('GetNodeDetail', snapshot.nodeId)
if (node) { if (!node) {
await selectNode(node) return false
activeTab = snapshot.tab || 'overview'
if (activeTab === 'files' && fileItems.length === 0) {
await loadFolder(node.id)
}
} }
await selectNode(node)
activeTab = snapshot.tab || 'overview'
if (activeTab === 'files' && fileItems.length === 0) {
await loadFolder(node.id)
}
return true
} else if (snapshot.section) { } else if (snapshot.section) {
if (!systemViews.some(view => view.id === snapshot.section)) {
return false
}
await selectSystemView(snapshot.section) await selectSystemView(snapshot.section)
if (snapshot.section === 'trash') { if (snapshot.section === 'trash') {
trashFolderId = snapshot.trashFolderId || '' trashFolderId = snapshot.trashFolderId || ''
@ -319,7 +324,11 @@
trashSelectedIds = [] trashSelectedIds = []
await refreshTrash() await refreshTrash()
} }
return true
} }
return false
} catch (e) {
return false
} finally { } finally {
restoringHistory = false restoringHistory = false
} }
@ -327,10 +336,11 @@
async function goBack() { async function goBack() {
if (closeTopModalForBack()) return if (closeTopModalForBack()) return
const snapshot = navHistory[navHistory.length - 1] while (navHistory.length > 0) {
if (!snapshot) return const snapshot = navHistory[navHistory.length - 1]
navHistory = navHistory.slice(0, -1) navHistory = navHistory.slice(0, -1)
await restoreNavigation(snapshot) if (await restoreNavigation(snapshot)) return
}
} }
function handleMouseNav(e) { function handleMouseNav(e) {

View File

@ -356,6 +356,13 @@ async function runReadyScenario(cdp, url) {
await assertEval(cdp, `!document.querySelector('.activity-feed-header h2')`, 'activity: screen title is not duplicated inside body') await assertEval(cdp, `!document.querySelector('.activity-feed-header h2')`, 'activity: screen title is not duplicated inside body')
await assertText(cdp, 'Smoke activity', 'activity feed: event visible') await assertText(cdp, 'Smoke activity', 'activity feed: event visible')
await clickText(cdp, '.nav-item', 'Сегодня')
await clickText(cdp, '.tree-label', 'Smoke Client')
await clickText(cdp, '.tree-label', 'Smoke Project')
await deleteSmokeNode(cdp, 'node-client')
await dispatchBodyKeydown(cdp, 'Backspace')
await assertEval(cdp, `document.querySelector('.header-title')?.innerText.trim() === 'Сегодня'`, 'navigation: Backspace skips deleted history entries')
await click(cdp, '.nav-add-btn') await click(cdp, '.nav-add-btn')
await waitForSelector(cdp, '.modal-create') await waitForSelector(cdp, '.modal-create')
await assertText(cdp, 'Создать элемент', 'create node: modal opens') await assertText(cdp, 'Создать элемент', 'create node: modal opens')
@ -528,6 +535,15 @@ async function dispatchMouseBack(cdp) {
await sleep(150) await sleep(150)
} }
async function deleteSmokeNode(cdp, id) {
await cdp.send('Runtime.evaluate', {
expression: `window.__VERSTAK_GUI_SMOKE__.deleteNode(${JSON.stringify(id)})`,
awaitPromise: true,
returnByValue: true,
})
await sleep(150)
}
async function setClipboardText(cdp, value) { async function setClipboardText(cdp, value) {
await cdp.send('Runtime.evaluate', { await cdp.send('Runtime.evaluate', {
expression: `window.__VERSTAK_GUI_SMOKE_CLIPBOARD__ = ${JSON.stringify(value)}`, expression: `window.__VERSTAK_GUI_SMOKE_CLIPBOARD__ = ${JSON.stringify(value)}`,
@ -1347,6 +1363,9 @@ function wailsMockSource() {
dropFiles: async (paths) => { dropFiles: async (paths) => {
if (runtimeHandlers['files-dropped']) await runtimeHandlers['files-dropped'](paths); if (runtimeHandlers['files-dropped']) await runtimeHandlers['files-dropped'](paths);
}, },
deleteNode: async (id) => {
detachNode(id);
},
}; };
})(); })();
` `