Merge pull request #2081 from overleaf/cmg-per-user-trash

Add per-user trashed state to project model

GitOrigin-RevId: 16a753702d3503eee011dd2adca5dc8df3da87f4
This commit is contained in:
Chrystal Maria Griffiths
2019-08-27 11:38:17 +01:00
committed by sharelatex
parent c1f8ac8de1
commit 6f2b4d3da3
7 changed files with 84 additions and 23 deletions
@@ -31,10 +31,27 @@ module.exports = ProjectHelper = {
if (Array.isArray(project.archived)) {
return project.archived.find(id => id.equals(userId)) !== undefined
} else {
return project.archived
return !!project.archived
}
},
isTrashed(project, userId) {
userId = ObjectId(userId)
if (project.trashed) {
return project.trashed.find(id => id.equals(userId)) !== undefined
} else {
return false
}
},
isArchivedOrTrashed(project, userId) {
return (
ProjectHelper.isArchived(project, userId) ||
ProjectHelper.isTrashed(project, userId)
)
},
ensureNameIsUnique(nameList, name, suffixes, maxLength, callback) {
// create a set of all project names
if (suffixes == null) {