fix: address PR review feedback

- Translate Chinese comments to English in useInPlaceEdit.ts
- Add guard in handleBlur to prevent double save when isSaving is true
- Update comment to clarify "prevent N refresh events" -> "prevent multiple refresh events"
- Add better error handling when all files fail to get system paths in uploadNotes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
suyao 2025-12-07 21:27:59 +08:00
parent f4f8e844ce
commit 2863961349
No known key found for this signature in database
2 changed files with 13 additions and 10 deletions

View File

@ -109,13 +109,12 @@ export function useInPlaceEdit(options: UseInPlaceEditOptions): UseInPlaceEditRe
}, [])
const handleBlur = useCallback(() => {
// 这里的逻辑需要注意:
// 如果点击了“取消”按钮,可能会先触发 Blur 保存。
// 通常 InPlaceEdit 的逻辑是 Blur 即 Save。
// 如果不想 Blur 保存,可以去掉这一行,或者判断 relatedTarget。
if (!isSaving) {
saveEdit()
}
// Note: The logic here requires attention:
// If the "Cancel" button is clicked, a blur event may trigger a save first.
// Typically, InPlaceEdit saves on blur.
// If you do not want to save on blur, you can remove this line or check relatedTarget.
if (isSaving) return
saveEdit()
}, [saveEdit, isSaving])
return {
@ -130,7 +129,7 @@ export function useInPlaceEdit(options: UseInPlaceEditOptions): UseInPlaceEditRe
onChange: handleInputChange,
onKeyDown: handleKeyDown,
onBlur: handleBlur,
disabled: isSaving // 保存时禁用输入
disabled: isSaving // Disable input while saving
}
}
}

View File

@ -127,6 +127,10 @@ export async function uploadNotes(
}
if (filePaths.length === 0) {
// If all files failed to get system paths, show an error toast
if (totalFiles > 0) {
window.toast.error('Failed to access any of the selected files. Please try selecting the files again.')
}
return {
uploadedNodes: [],
totalFiles,
@ -136,7 +140,7 @@ export async function uploadNotes(
}
}
// Pause file watcher to prevent N refresh events
// Pause file watcher to prevent multiple refresh events
await window.api.file.pauseFileWatcher()
// Use simplified batchUpload for File objects
@ -174,7 +178,7 @@ async function uploadNotesRecursive(
const basePath = normalizePath(targetPath)
try {
// Pause file watcher to prevent N refresh events
// Pause file watcher to prevent multiple refresh events
await window.api.file.pauseFileWatcher()
try {