mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
66dc566752
History migration: Ignore binary files when auto-selecting file to display in history view GitOrigin-RevId: 7d2a314cdb3d54e4e2292a95e7633e3829ea931f
30 lines
834 B
TypeScript
30 lines
834 B
TypeScript
import type {
|
|
FileDiff,
|
|
FileRemoved,
|
|
FileRenamed,
|
|
FileWithEditable,
|
|
} 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'
|
|
}
|
|
|
|
function isFileWithEditable(fileDiff: FileDiff): fileDiff is FileWithEditable {
|
|
return 'editable' in (fileDiff as FileWithEditable)
|
|
}
|
|
|
|
export function isFileEditable(fileDiff: FileDiff) {
|
|
return isFileWithEditable(fileDiff)
|
|
? fileDiff.editable
|
|
: fileDiff.operation === 'edited'
|
|
}
|
|
|
|
export function fileFinalPathname(fileDiff: FileDiff) {
|
|
return (
|
|
(isFileRenamed(fileDiff) ? fileDiff.newPathname : null) || fileDiff.pathname
|
|
)
|
|
}
|