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;
}
</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">
</head>
<body>

View File

@ -304,14 +304,19 @@
try {
if (snapshot.nodeId) {
const node = await wailsCall('GetNodeDetail', snapshot.nodeId)
if (node) {
if (!node) {
return false
}
await selectNode(node)
activeTab = snapshot.tab || 'overview'
if (activeTab === 'files' && fileItems.length === 0) {
await loadFolder(node.id)
}
}
return true
} else if (snapshot.section) {
if (!systemViews.some(view => view.id === snapshot.section)) {
return false
}
await selectSystemView(snapshot.section)
if (snapshot.section === 'trash') {
trashFolderId = snapshot.trashFolderId || ''
@ -319,7 +324,11 @@
trashSelectedIds = []
await refreshTrash()
}
return true
}
return false
} catch (e) {
return false
} finally {
restoringHistory = false
}
@ -327,10 +336,11 @@
async function goBack() {
if (closeTopModalForBack()) return
while (navHistory.length > 0) {
const snapshot = navHistory[navHistory.length - 1]
if (!snapshot) return
navHistory = navHistory.slice(0, -1)
await restoreNavigation(snapshot)
if (await restoreNavigation(snapshot)) return
}
}
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 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 waitForSelector(cdp, '.modal-create')
await assertText(cdp, 'Создать элемент', 'create node: modal opens')
@ -528,6 +535,15 @@ async function dispatchMouseBack(cdp) {
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) {
await cdp.send('Runtime.evaluate', {
expression: `window.__VERSTAK_GUI_SMOKE_CLIPBOARD__ = ${JSON.stringify(value)}`,
@ -1347,6 +1363,9 @@ function wailsMockSource() {
dropFiles: async (paths) => {
if (runtimeHandlers['files-dropped']) await runtimeHandlers['files-dropped'](paths);
},
deleteNode: async (id) => {
detachNode(id);
},
};
})();
`