mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 14:29:15 +08:00
fix: cancel debounced save on file path update (#11069)
Adds cancellation of the debounced save when the active file path is updated after moving a file or folder. This prevents saving to the old path and ensures lastFilePathRef is updated accordingly.
This commit is contained in:
parent
82ca35fc29
commit
1018ad87b8
@ -716,10 +716,17 @@ const NotesPage: FC = () => {
|
|||||||
const normalizedActivePath = activeFilePath ? normalizePathValue(activeFilePath) : undefined
|
const normalizedActivePath = activeFilePath ? normalizePathValue(activeFilePath) : undefined
|
||||||
if (normalizedActivePath) {
|
if (normalizedActivePath) {
|
||||||
if (normalizedActivePath === sourceNode.externalPath) {
|
if (normalizedActivePath === sourceNode.externalPath) {
|
||||||
|
// Cancel debounced save to prevent saving to old path
|
||||||
|
debouncedSaveRef.current?.cancel()
|
||||||
|
lastFilePathRef.current = destinationPath
|
||||||
dispatch(setActiveFilePath(destinationPath))
|
dispatch(setActiveFilePath(destinationPath))
|
||||||
} else if (sourceNode.type === 'folder' && normalizedActivePath.startsWith(`${sourceNode.externalPath}/`)) {
|
} else if (sourceNode.type === 'folder' && normalizedActivePath.startsWith(`${sourceNode.externalPath}/`)) {
|
||||||
const suffix = normalizedActivePath.slice(sourceNode.externalPath.length)
|
const suffix = normalizedActivePath.slice(sourceNode.externalPath.length)
|
||||||
dispatch(setActiveFilePath(`${destinationPath}${suffix}`))
|
const newActivePath = `${destinationPath}${suffix}`
|
||||||
|
// Cancel debounced save to prevent saving to old path
|
||||||
|
debouncedSaveRef.current?.cancel()
|
||||||
|
lastFilePathRef.current = newActivePath
|
||||||
|
dispatch(setActiveFilePath(newActivePath))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user