overleaf/services/web/frontend/js/features/history/utils/file-diff.ts
June Kelly 6c2bc2fe8b Merge pull request #13068 from overleaf/td-history-renamed-file-auto-select
History migration: Fix bug that prevents renamed files being automatically selected

GitOrigin-RevId: ce127b218d1eb472fe7b35467a17549f3db4bfb7
2023-05-17 08:03:58 +00:00

13 lines
494 B
TypeScript

import type { FileDiff, FileRemoved, FileRenamed } from '../services/types/file'
export function isFileRenamed(fileDiff: FileDiff): fileDiff is FileRenamed {
return (fileDiff as FileRenamed).operation === 'renamed'
}
export function isFileRemoved(fileDiff: FileDiff): fileDiff is FileRemoved {
return (fileDiff as FileRemoved).operation === 'removed'
}
export function fileFinalPathname(fileDiff: FileDiff) {
return isFileRenamed(fileDiff) ? fileDiff.newPathname : fileDiff.pathname
}