mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -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,17 +71,23 @@ export function useRestoreDeletedFile() {
|
||||||
|
|
||||||
const restoreDeletedFile = useCallback(
|
const restoreDeletedFile = useCallback(
|
||||||
(selection: HistoryContextValue['selection']) => {
|
(selection: HistoryContextValue['selection']) => {
|
||||||
const { selectedFile } = selection
|
const { selectedFile, files } = selection
|
||||||
|
|
||||||
if (
|
if (
|
||||||
selectedFile &&
|
selectedFile &&
|
||||||
selectedFile.pathname &&
|
selectedFile.pathname &&
|
||||||
isFileRemoved(selectedFile)
|
isFileRemoved(selectedFile)
|
||||||
) {
|
) {
|
||||||
|
const file = files.find(file => file.pathname === selectedFile.pathname)
|
||||||
|
if (file && isFileRemoved(file)) {
|
||||||
sendMB('history-v2-restore-deleted')
|
sendMB('history-v2-restore-deleted')
|
||||||
|
|
||||||
setState('restoring')
|
setState('restoring')
|
||||||
restoreFile(projectId, selectedFile).then(
|
|
||||||
|
restoreFile(projectId, {
|
||||||
|
...selectedFile,
|
||||||
|
pathname: file.newPathname ?? file.pathname,
|
||||||
|
}).then(
|
||||||
(data: RestoreFileResponse) => {
|
(data: RestoreFileResponse) => {
|
||||||
setRestoredFileMetadata(data)
|
setRestoredFileMetadata(data)
|
||||||
setState('waitingForFileTree')
|
setState('waitingForFileTree')
|
||||||
|
@ -92,6 +98,7 @@ export function useRestoreDeletedFile() {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[handleError, projectId]
|
[handleError, projectId]
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue