add memberId to entity_changes to avoid having to resend all changes second time

This commit is contained in:
zadam
2022-01-09 20:16:39 +01:00
parent c448d34a38
commit 7159b13c9d
25 changed files with 11520 additions and 266 deletions

View File

@@ -9,8 +9,8 @@ export default class LoadResults {
}
}
this.noteIdToSourceId = {};
this.sourceIdToNoteIds = {};
this.noteIdToComponentId = {};
this.componentIdToNoteIds = {};
this.branches = [];
@@ -20,7 +20,7 @@ export default class LoadResults {
this.noteRevisions = [];
this.contentNoteIdToSourceId = [];
this.contentNoteIdToComponentId = [];
this.options = [];
}
@@ -29,22 +29,22 @@ export default class LoadResults {
return this.entities[entityName]?.[entityId];
}
addNote(noteId, sourceId) {
this.noteIdToSourceId[noteId] = this.noteIdToSourceId[noteId] || [];
addNote(noteId, componentId) {
this.noteIdToComponentId[noteId] = this.noteIdToComponentId[noteId] || [];
if (!this.noteIdToSourceId[noteId].includes(sourceId)) {
this.noteIdToSourceId[noteId].push(sourceId);
if (!this.noteIdToComponentId[noteId].includes(componentId)) {
this.noteIdToComponentId[noteId].push(componentId);
}
this.sourceIdToNoteIds[sourceId] = this.sourceIdToNoteIds[sourceId] || [];
this.componentIdToNoteIds[componentId] = this.componentIdToNoteIds[componentId] || [];
if (!this.sourceIdToNoteIds[sourceId]) {
this.sourceIdToNoteIds[sourceId].push(noteId);
if (!this.componentIdToNoteIds[componentId]) {
this.componentIdToNoteIds[componentId].push(noteId);
}
}
addBranch(branchId, sourceId) {
this.branches.push({branchId, sourceId});
addBranch(branchId, componentId) {
this.branches.push({branchId, componentId});
}
getBranches() {
@@ -53,7 +53,7 @@ export default class LoadResults {
.filter(branch => !!branch);
}
addNoteReordering(parentNoteId, sourceId) {
addNoteReordering(parentNoteId, componentId) {
this.noteReorderings.push(parentNoteId);
}
@@ -61,20 +61,20 @@ export default class LoadResults {
return this.noteReorderings;
}
addAttribute(attributeId, sourceId) {
this.attributes.push({attributeId, sourceId});
addAttribute(attributeId, componentId) {
this.attributes.push({attributeId, componentId});
}
/** @returns {Attribute[]} */
getAttributes(sourceId = 'none') {
getAttributes(componentId = 'none') {
return this.attributes
.filter(row => row.sourceId !== sourceId)
.filter(row => row.componentId !== componentId)
.map(row => this.getEntity("attributes", row.attributeId))
.filter(attr => !!attr);
}
addNoteRevision(noteRevisionId, noteId, sourceId) {
this.noteRevisions.push({noteRevisionId, noteId, sourceId});
addNoteRevision(noteRevisionId, noteId, componentId) {
this.noteRevisions.push({noteRevisionId, noteId, componentId});
}
hasNoteRevisionForNote(noteId) {
@@ -82,28 +82,28 @@ export default class LoadResults {
}
getNoteIds() {
return Object.keys(this.noteIdToSourceId);
return Object.keys(this.noteIdToComponentId);
}
isNoteReloaded(noteId, sourceId = null) {
isNoteReloaded(noteId, componentId = null) {
if (!noteId) {
return false;
}
const sourceIds = this.noteIdToSourceId[noteId];
return sourceIds && !!sourceIds.find(sId => sId !== sourceId);
const componentIds = this.noteIdToComponentId[noteId];
return componentIds && !!componentIds.find(sId => sId !== componentId);
}
addNoteContent(noteId, sourceId) {
this.contentNoteIdToSourceId.push({noteId, sourceId});
addNoteContent(noteId, componentId) {
this.contentNoteIdToComponentId.push({noteId, componentId});
}
isNoteContentReloaded(noteId, sourceId) {
isNoteContentReloaded(noteId, componentId) {
if (!noteId) {
return false;
}
return this.contentNoteIdToSourceId.find(l => l.noteId === noteId && l.sourceId !== sourceId);
return this.contentNoteIdToComponentId.find(l => l.noteId === noteId && l.componentId !== componentId);
}
addOption(name) {
@@ -124,17 +124,17 @@ export default class LoadResults {
}
isEmpty() {
return Object.keys(this.noteIdToSourceId).length === 0
return Object.keys(this.noteIdToComponentId).length === 0
&& this.branches.length === 0
&& this.attributes.length === 0
&& this.noteReorderings.length === 0
&& this.noteRevisions.length === 0
&& this.contentNoteIdToSourceId.length === 0
&& this.contentNoteIdToComponentId.length === 0
&& this.options.length === 0;
}
isEmptyForTree() {
return Object.keys(this.noteIdToSourceId).length === 0
return Object.keys(this.noteIdToComponentId).length === 0
&& this.branches.length === 0
&& this.attributes.length === 0
&& this.noteReorderings.length === 0;