fix: openActivityTarget navigates to parent folder and previews files

- resolveActivityTarget uses 'targetId'/'targetPath' for all types
  (note, file, folder) instead of type-specific property names
- openActivityTarget for files: resolves the file node via
  GetNodeDetail, navigates to its parent folder in the Files tab,
  then auto-previews the file if it's a previewable type
- For root-level files (no parent_id): loads root items
- Removed spurious OpenFolder(targetPath) call that silently failed
  because OpenFolder expects a node ID, not a filesystem path
This commit is contained in:
mirivlad 2026-06-03 17:32:18 +08:00
parent 4ec03c849f
commit e30a75c5a0
4 changed files with 26 additions and 12 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -16,7 +16,7 @@
background: #13131f; background: #13131f;
} }
</style> </style>
<script type="module" crossorigin src="/assets/main-B4NdnBxC.js"></script> <script type="module" crossorigin src="/assets/main-D_8wOpYY.js"></script>
<link rel="stylesheet" crossorigin href="/assets/main-BafVhx43.css"> <link rel="stylesheet" crossorigin href="/assets/main-BafVhx43.css">
</head> </head>
<body> <body>

View File

@ -1345,19 +1345,33 @@
selectNode(node) selectNode(node)
if (target.tab === 'notes') { if (target.tab === 'notes') {
activeTab = 'notes' activeTab = 'notes'
if (target.noteId) { if (target.targetId) {
try { notes = await wailsCall('ListNotes', targetNode) || [] } catch(e) {} try { notes = await wailsCall('ListNotes', targetNode) || [] } catch(e) {}
const note = notes.find(n => n.id === target.noteId) const note = notes.find(n => n.id === target.targetId)
if (note) setTimeout(() => openNote(note), 100) if (note) setTimeout(() => openNote(note), 100)
} }
} else if (target.tab === 'files') { } else if (target.tab === 'files') {
activeTab = 'files' activeTab = 'files'
// Without explicit loadFolder the files tab stays empty because selectNode if (target.targetId) {
// resets fileItems and the tab's click handler doesn't fire on programmatic toggle. // targetId is the node ID of the file/folder in the tree.
await loadFolder(selectedNode.id) // Navigate to its parent folder so the user sees context.
// target.targetPath is a filesystem path; OpenFolder opens the system file manager. try {
if (target.targetPath) { const detail = await wailsCall('GetNodeDetail', target.targetId)
try { await wailsCall('OpenFolder', target.targetPath) } catch(e) {} if (detail && detail.parent_id) {
await loadFolder(detail.parent_id)
const fileItem = fileItems.find(f => f.id === target.targetId)
if (fileItem && fileItem.type === 'file' && canPreviewFile(fileItem)) {
setTimeout(() => openPreview(fileItem), 150)
}
} else {
// No parent — item sits at the root level
await loadFolder(targetNode)
}
} catch(e) {
await loadFolder(targetNode)
}
} else {
await loadFolder(targetNode)
} }
} }
} catch (e) { } catch (e) {