mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Use newPathname
when restoring a renamed file from history (#15534)
GitOrigin-RevId: b8f6b7d6174f814db696002891addb961e76ac9c
This commit is contained in:
parent
a5faeee707
commit
6b8dfaa782
1 changed files with 20 additions and 13 deletions
|
@ -71,26 +71,33 @@ export function useRestoreDeletedFile() {
|
|||
|
||||
const restoreDeletedFile = useCallback(
|
||||
(selection: HistoryContextValue['selection']) => {
|
||||
const { selectedFile } = selection
|
||||
const { selectedFile, files } = selection
|
||||
|
||||
if (
|
||||
selectedFile &&
|
||||
selectedFile.pathname &&
|
||||
isFileRemoved(selectedFile)
|
||||
) {
|
||||
sendMB('history-v2-restore-deleted')
|
||||
const file = files.find(file => file.pathname === selectedFile.pathname)
|
||||
if (file && isFileRemoved(file)) {
|
||||
sendMB('history-v2-restore-deleted')
|
||||
|
||||
setState('restoring')
|
||||
restoreFile(projectId, selectedFile).then(
|
||||
(data: RestoreFileResponse) => {
|
||||
setRestoredFileMetadata(data)
|
||||
setState('waitingForFileTree')
|
||||
},
|
||||
error => {
|
||||
setState('error')
|
||||
handleError(error)
|
||||
}
|
||||
)
|
||||
setState('restoring')
|
||||
|
||||
restoreFile(projectId, {
|
||||
...selectedFile,
|
||||
pathname: file.newPathname ?? file.pathname,
|
||||
}).then(
|
||||
(data: RestoreFileResponse) => {
|
||||
setRestoredFileMetadata(data)
|
||||
setState('waitingForFileTree')
|
||||
},
|
||||
error => {
|
||||
setState('error')
|
||||
handleError(error)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
[handleError, projectId]
|
||||
|
|
Loading…
Reference in a new issue