Merge pull request #26575 from overleaf/jpa-archived-state
[web] remove runtime migration for project.archived/trashed state GitOrigin-RevId: 69064878f3dfdcde3727a4e3eb555deb75c70588
This commit is contained in:
@@ -20,7 +20,6 @@ module.exports = {
|
||||
isArchived,
|
||||
isTrashed,
|
||||
isArchivedOrTrashed,
|
||||
calculateArchivedArray,
|
||||
ensureNameIsUnique,
|
||||
getAllowedImagesForUser,
|
||||
promises: {
|
||||
@@ -63,38 +62,6 @@ function isArchivedOrTrashed(project, userId) {
|
||||
return isArchived(project, userId) || isTrashed(project, userId)
|
||||
}
|
||||
|
||||
function _allCollaborators(project) {
|
||||
return _.unionWith(
|
||||
[project.owner_ref],
|
||||
project.collaberator_refs,
|
||||
project.readOnly_refs,
|
||||
project.tokenAccessReadAndWrite_refs,
|
||||
project.tokenAccessReadOnly_refs,
|
||||
_objectIdEquals
|
||||
)
|
||||
}
|
||||
|
||||
function calculateArchivedArray(project, userId, action) {
|
||||
let archived = project.archived
|
||||
userId = new ObjectId(userId)
|
||||
|
||||
if (archived === true) {
|
||||
archived = _allCollaborators(project)
|
||||
} else if (!archived) {
|
||||
archived = []
|
||||
}
|
||||
|
||||
if (action === 'ARCHIVE') {
|
||||
archived = _.unionWith(archived, [userId], _objectIdEquals)
|
||||
} else if (action === 'UNARCHIVE') {
|
||||
archived = archived.filter(id => !_objectIdEquals(id, userId))
|
||||
} else {
|
||||
throw new Error('Unrecognised action')
|
||||
}
|
||||
|
||||
return archived
|
||||
}
|
||||
|
||||
function ensureNameIsUnique(nameList, name, suffixes, maxLength, callback) {
|
||||
// create a set of all project names
|
||||
if (suffixes == null) {
|
||||
@@ -122,11 +89,6 @@ function ensureNameIsUnique(nameList, name, suffixes, maxLength, callback) {
|
||||
}
|
||||
}
|
||||
|
||||
function _objectIdEquals(firstVal, secondVal) {
|
||||
// For use as a comparator for unionWith
|
||||
return firstVal.toString() === secondVal.toString()
|
||||
}
|
||||
|
||||
function _addSuffixToProjectName(name, suffix, maxLength) {
|
||||
// append the suffix and truncate the project title if needed
|
||||
if (suffix == null) {
|
||||
|
||||
Reference in New Issue
Block a user