mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-04 19:44:55 -05:00
14 lines
436 B
JavaScript
14 lines
436 B
JavaScript
|
import { findInTree } from '../util/find-in-tree'
|
||
|
|
||
|
export function isNameUniqueInFolder(tree, parentFolderId, name) {
|
||
|
if (tree._id !== parentFolderId) {
|
||
|
tree = findInTree(tree, parentFolderId).entity
|
||
|
}
|
||
|
|
||
|
if (tree.docs.some(entity => entity.name === name)) return false
|
||
|
if (tree.fileRefs.some(entity => entity.name === name)) return false
|
||
|
if (tree.folders.some(entity => entity.name === name)) return false
|
||
|
|
||
|
return true
|
||
|
}
|