Fixes
This commit is contained in:
@@ -142,7 +142,7 @@ const Atlas = sequelize.define('atlas', {
|
||||
|
||||
return newTree;
|
||||
},
|
||||
async addNodeToNavigationTree(document) {
|
||||
addNodeToNavigationTree(document) {
|
||||
const newNode = {
|
||||
id: document.id,
|
||||
title: document.title,
|
||||
@@ -163,6 +163,7 @@ const Atlas = sequelize.define('atlas', {
|
||||
};
|
||||
|
||||
this.navigationTree = insertNode(this.navigationTree);
|
||||
return this.navigationTree;
|
||||
},
|
||||
async deleteDocument(document) {
|
||||
const deleteNodeAndDocument = async (node, documentId, shouldDelete = false) => {
|
||||
|
||||
@@ -35,9 +35,16 @@ const documentBeforeSave = async (doc) => {
|
||||
doc.revisionCount = doc.revisionCount + 1;
|
||||
|
||||
// Collaborators
|
||||
const ids = await Revision.findAll({
|
||||
attributes: [[DataTypes.literal('DISTINCT "userId"'), 'userId']],
|
||||
}).map(rev => rev.userId);
|
||||
let ids = [];
|
||||
// Only get previous user IDs if the document already exists
|
||||
if (doc.id) {
|
||||
ids = await Revision.findAll({
|
||||
attributes: [[DataTypes.literal('DISTINCT "userId"'), 'userId']],
|
||||
where: {
|
||||
documentId: doc.id,
|
||||
},
|
||||
}).map(rev => rev.userId);
|
||||
}
|
||||
// We'll add the current user as revision hasn't been generated yet
|
||||
ids.push(doc.lastModifiedById);
|
||||
doc.collaboratorIds = _.uniq(ids);
|
||||
|
||||
Reference in New Issue
Block a user