Merge pull request #10086 from overleaf/ii-dashboard-duplicate-projects

[web] Project dashboard duplicate projects

GitOrigin-RevId: ce21a1401769b694bf06a0a33c3d6684b407a47b
This commit is contained in:
ilkin-overleaf 2022-10-21 14:33:08 +03:00 committed by Copybot
parent f8e98cd5c6
commit 185ccde5a0

View file

@ -389,14 +389,14 @@ function _formatProjects(projects, userId) {
// Only add these formattedProjects if they're not already present, this gives us cascading access // Only add these formattedProjects if they're not already present, this gives us cascading access
// from 'owner' => 'token-read-only' // from 'owner' => 'token-read-only'
for (const project of tokenReadAndWrite) { for (const project of tokenReadAndWrite) {
if (!_.find(formattedProjects, ['id', project._id.toString()])) { if (!formattedProjects.some(p => p.id === project._id.toString())) {
formattedProjects.push( formattedProjects.push(
_formatProjectInfo(project, 'readAndWrite', Sources.TOKEN, userId) _formatProjectInfo(project, 'readAndWrite', Sources.TOKEN, userId)
) )
} }
} }
for (const project of tokenReadOnly) { for (const project of tokenReadOnly) {
if (!_.find(formattedProjects, ['id', project._id.toString()])) { if (!formattedProjects.some(p => p.id === project._id.toString())) {
formattedProjects.push( formattedProjects.push(
_formatProjectInfo(project, 'readOnly', Sources.TOKEN, userId) _formatProjectInfo(project, 'readOnly', Sources.TOKEN, userId)
) )
@ -458,7 +458,7 @@ function _formatProjectInfo(project, accessLevel, source, userId) {
const trashed = ProjectHelper.isTrashed(project, userId) && !archived const trashed = ProjectHelper.isTrashed(project, userId) && !archived
const model = { const model = {
id: project._id, id: project._id.toString(),
name: project.name, name: project.name,
owner_ref: project.owner_ref, owner_ref: project.owner_ref,
lastUpdated: project.lastUpdated, lastUpdated: project.lastUpdated,